diff options
Diffstat (limited to '')
-rw-r--r-- | include/freerdp/utils/aad.h | 35 | ||||
-rw-r--r-- | include/freerdp/utils/cliprdr_utils.h | 51 | ||||
-rw-r--r-- | include/freerdp/utils/drdynvc.h | 39 | ||||
-rw-r--r-- | include/freerdp/utils/encoded_types.h | 40 | ||||
-rw-r--r-- | include/freerdp/utils/gfx.h | 41 | ||||
-rw-r--r-- | include/freerdp/utils/http.h | 75 | ||||
-rw-r--r-- | include/freerdp/utils/passphrase.h | 44 | ||||
-rw-r--r-- | include/freerdp/utils/pcap.h | 80 | ||||
-rw-r--r-- | include/freerdp/utils/pod_arrays.h | 138 | ||||
-rw-r--r-- | include/freerdp/utils/profiler.h | 99 | ||||
-rw-r--r-- | include/freerdp/utils/proxy_utils.h | 37 | ||||
-rw-r--r-- | include/freerdp/utils/rdpdr_utils.h | 72 | ||||
-rw-r--r-- | include/freerdp/utils/ringbuffer.h | 131 | ||||
-rw-r--r-- | include/freerdp/utils/signal.h | 63 | ||||
-rw-r--r-- | include/freerdp/utils/smartcard_call.h | 65 | ||||
-rw-r--r-- | include/freerdp/utils/smartcard_operations.h | 96 | ||||
-rw-r--r-- | include/freerdp/utils/smartcard_pack.h | 186 | ||||
-rw-r--r-- | include/freerdp/utils/smartcardlogon.h | 62 | ||||
-rw-r--r-- | include/freerdp/utils/stopwatch.h | 54 | ||||
-rw-r--r-- | include/freerdp/utils/string.h | 40 |
20 files changed, 1448 insertions, 0 deletions
diff --git a/include/freerdp/utils/aad.h b/include/freerdp/utils/aad.h new file mode 100644 index 0000000..c59e83c --- /dev/null +++ b/include/freerdp/utils/aad.h @@ -0,0 +1,35 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Network Level Authentication (NLA) + * + * Copyright 2023 Armin Novak <anovak@thincast.com> + * Copyright 2023 Thincast Technologies GmbH + * + * 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. + */ + +#ifndef FREERDP_UTILS_AAD_H +#define FREERDP_UTILS_AAD_H + +#include <winpr/wlog.h> + +#include <freerdp/api.h> +#include <freerdp/config.h> + +#ifdef WITH_AAD + +FREERDP_API char* freerdp_utils_aad_get_access_token(wLog* log, const char* data, size_t length); + +#endif + +#endif /* FREERDP_UTILS_AAD_H */ diff --git a/include/freerdp/utils/cliprdr_utils.h b/include/freerdp/utils/cliprdr_utils.h new file mode 100644 index 0000000..0b3295b --- /dev/null +++ b/include/freerdp/utils/cliprdr_utils.h @@ -0,0 +1,51 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * RDPDR utility functions + * + * Copyright 2022 Armin Novak <armin.novak@thincast.com> + * Copyright 2022 Thincast Technologies GmbH + * + * 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. + */ + +#ifndef FREERDP_UTILS_CLIPRDR_H +#define FREERDP_UTILS_CLIPRDR_H + +#include <winpr/wtypes.h> +#include <winpr/shell.h> +#include <freerdp/api.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + FREERDP_API BOOL cliprdr_read_filedescriptor(wStream* s, FILEDESCRIPTORW* descriptor); + FREERDP_API BOOL cliprdr_write_filedescriptor(wStream* s, const FILEDESCRIPTORW* descriptor); + + FREERDP_API UINT cliprdr_parse_file_list(const BYTE* format_data, UINT32 format_data_length, + FILEDESCRIPTORW** file_descriptor_array, + UINT32* file_descriptor_count); + FREERDP_API UINT cliprdr_serialize_file_list(const FILEDESCRIPTORW* file_descriptor_array, + UINT32 file_descriptor_count, BYTE** format_data, + UINT32* format_data_length); + FREERDP_API UINT cliprdr_serialize_file_list_ex(UINT32 flags, + const FILEDESCRIPTORW* file_descriptor_array, + UINT32 file_descriptor_count, + BYTE** format_data, UINT32* format_data_length); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/freerdp/utils/drdynvc.h b/include/freerdp/utils/drdynvc.h new file mode 100644 index 0000000..cc96d95 --- /dev/null +++ b/include/freerdp/utils/drdynvc.h @@ -0,0 +1,39 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * + * GFX Utils - Helper functions converting something to string + * + * Copyright 2023 Armin Novak <armin.novak@thincast.com> + * Copyright 2023 Thincast Technologies GmbH + * + * 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. + */ + +#ifndef FREERDP_UTILS_DRDYNVC_H +#define FREERDP_UTILS_DRDYNVC_H + +#include <winpr/wtypes.h> +#include <freerdp/api.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + FREERDP_API const char* drdynvc_get_packet_type(BYTE cmd); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/freerdp/utils/encoded_types.h b/include/freerdp/utils/encoded_types.h new file mode 100644 index 0000000..b3852fe --- /dev/null +++ b/include/freerdp/utils/encoded_types.h @@ -0,0 +1,40 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * + * Helper functions to parse encoded types into regular ones + * + * Copyright 2023 Pascal Nowack <Pascal.Nowack@gmx.de> + * + * 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. + */ + +#ifndef FREERDP_UTILS_ENCODED_TYPES_H +#define FREERDP_UTILS_ENCODED_TYPES_H + +#include <freerdp/api.h> +#include <winpr/stream.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + FREERDP_API BOOL freerdp_read_four_byte_signed_integer(wStream* s, INT32* value); + + FREERDP_API BOOL freerdp_read_four_byte_float(wStream* s, double* value); + +#ifdef __cplusplus +} +#endif + +#endif /* FREERDP_UTILS_ENCODED_TYPES_H */ diff --git a/include/freerdp/utils/gfx.h b/include/freerdp/utils/gfx.h new file mode 100644 index 0000000..0f5c189 --- /dev/null +++ b/include/freerdp/utils/gfx.h @@ -0,0 +1,41 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * + * GFX Utils - Helper functions converting something to string + * + * Copyright 2022 Armin Novak <armin.novak@thincast.com> + * Copyright 2022 Thincast Technologies GmbH + * + * 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. + */ + +#ifndef FREERDP_UTILS_GFX_H +#define FREERDP_UTILS_GFX_H + +#include <winpr/wtypes.h> +#include <freerdp/api.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + FREERDP_API const char* rdpgfx_get_cmd_id_string(UINT16 cmdId); + + FREERDP_API const char* rdpgfx_get_codec_id_string(UINT16 codecId); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/freerdp/utils/http.h b/include/freerdp/utils/http.h new file mode 100644 index 0000000..9719402 --- /dev/null +++ b/include/freerdp/utils/http.h @@ -0,0 +1,75 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Smartcard Device Service Virtual Channel + * + * Copyright 2023 Isaac Klein <fifthdegree@protonmail.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. + */ + +#ifndef FREERDP_UTILS_HTTP_H +#define FREERDP_UTILS_HTTP_H + +#include <freerdp/api.h> + +typedef enum +{ + HTTP_STATUS_CONTINUE = 100, + HTTP_STATUS_SWITCH_PROTOCOLS = 101, + HTTP_STATUS_OK = 200, + HTTP_STATUS_CREATED = 201, + HTTP_STATUS_ACCEPTED = 202, + HTTP_STATUS_PARTIAL = 203, + HTTP_STATUS_NO_CONTENT = 204, + HTTP_STATUS_RESET_CONTENT = 205, + HTTP_STATUS_PARTIAL_CONTENT = 206, + HTTP_STATUS_WEBDAV_MULTI_STATUS = 207, + HTTP_STATUS_AMBIGUOUS = 300, + HTTP_STATUS_MOVED = 301, + HTTP_STATUS_REDIRECT = 302, + HTTP_STATUS_REDIRECT_METHOD = 303, + HTTP_STATUS_NOT_MODIFIED = 304, + HTTP_STATUS_USE_PROXY = 305, + HTTP_STATUS_REDIRECT_KEEP_VERB = 307, + HTTP_STATUS_BAD_REQUEST = 400, + HTTP_STATUS_DENIED = 401, + HTTP_STATUS_PAYMENT_REQ = 402, + HTTP_STATUS_FORBIDDEN = 403, + HTTP_STATUS_NOT_FOUND = 404, + HTTP_STATUS_BAD_METHOD = 405, + HTTP_STATUS_NONE_ACCEPTABLE = 406, + HTTP_STATUS_PROXY_AUTH_REQ = 407, + HTTP_STATUS_REQUEST_TIMEOUT = 408, + HTTP_STATUS_CONFLICT = 409, + HTTP_STATUS_GONE = 410, + HTTP_STATUS_LENGTH_REQUIRED = 411, + HTTP_STATUS_PRECOND_FAILED = 412, + HTTP_STATUS_REQUEST_TOO_LARGE = 413, + HTTP_STATUS_URI_TOO_LONG = 414, + HTTP_STATUS_UNSUPPORTED_MEDIA = 415, + HTTP_STATUS_RETRY_WITH = 449, + HTTP_STATUS_SERVER_ERROR = 500, + HTTP_STATUS_NOT_SUPPORTED = 501, + HTTP_STATUS_BAD_GATEWAY = 502, + HTTP_STATUS_SERVICE_UNAVAIL = 503, + HTTP_STATUS_GATEWAY_TIMEOUT = 504, + HTTP_STATUS_VERSION_NOT_SUP = 505 +} FREERDP_HTTP_STATUS; + +FREERDP_API BOOL freerdp_http_request(const char* url, const char* body, long* status_code, + BYTE** response, size_t* response_length); + +FREERDP_API const char* freerdp_http_status_string(long status); +FREERDP_API char* freerdp_http_status_string_format(long status, char* buffer, size_t size); + +#endif /* FREERDP_UTILS_HTTP_H */ diff --git a/include/freerdp/utils/passphrase.h b/include/freerdp/utils/passphrase.h new file mode 100644 index 0000000..f6a0f96 --- /dev/null +++ b/include/freerdp/utils/passphrase.h @@ -0,0 +1,44 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Passphrase Handling Utils + * + * Copyright 2011 Shea Levy <shea@shealevy.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. + */ + +#ifndef FREERDP_UTILS_PASSPHRASE_H +#define FREERDP_UTILS_PASSPHRASE_H + +#include <stdlib.h> +#include <stdio.h> + +#include <freerdp/api.h> +#include <freerdp/types.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + FREERDP_API int freerdp_interruptible_getc(rdpContext* context, FILE* file); + FREERDP_API SSIZE_T freerdp_interruptible_get_line(rdpContext* context, char** lineptr, + size_t* size, FILE* stream); + FREERDP_API char* freerdp_passphrase_read(rdpContext* context, const char* prompt, char* buf, + size_t bufsiz, int from_stdin); + +#ifdef __cplusplus +} +#endif + +#endif /* FREERDP_UTILS_PASSPHRASE_H */ diff --git a/include/freerdp/utils/pcap.h b/include/freerdp/utils/pcap.h new file mode 100644 index 0000000..5178f38 --- /dev/null +++ b/include/freerdp/utils/pcap.h @@ -0,0 +1,80 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * pcap File Format Utils + * + * Copyright 2011 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. + */ + +#ifndef FREERDP_UTILS_PCAP_H +#define FREERDP_UTILS_PCAP_H + +#include <freerdp/api.h> +#include <freerdp/types.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct + { + UINT32 magic_number; /* magic number */ + UINT16 version_major; /* major version number */ + UINT16 version_minor; /* minor version number */ + INT32 thiszone; /* GMT to local correction */ + UINT32 sigfigs; /* accuracy of timestamps */ + UINT32 snaplen; /* max length of captured packets, in octets */ + UINT32 network; /* data link type */ + } pcap_header; + + typedef struct + { + UINT32 ts_sec; /* timestamp seconds */ + UINT32 ts_usec; /* timestamp microseconds */ + UINT32 incl_len; /* number of octets of packet saved in file */ + UINT32 orig_len; /* actual length of packet */ + } pcap_record_header; + + typedef struct s_pcap_record pcap_record; + + struct s_pcap_record + { + pcap_record_header header; + union + { + void* data; + const void* cdata; + }; + UINT32 length; + pcap_record* next; + }; + + typedef struct rdp_pcap rdpPcap; + + FREERDP_API rdpPcap* pcap_open(const char* name, BOOL write); + FREERDP_API void pcap_close(rdpPcap* pcap); + + FREERDP_API BOOL pcap_add_record(rdpPcap* pcap, const void* data, size_t length); + FREERDP_API BOOL pcap_has_next_record(const rdpPcap* pcap); + FREERDP_API BOOL pcap_get_next_record(rdpPcap* pcap, pcap_record* record); + FREERDP_API BOOL pcap_get_next_record_header(rdpPcap* pcap, pcap_record* record); + FREERDP_API BOOL pcap_get_next_record_content(rdpPcap* pcap, pcap_record* record); + FREERDP_API void pcap_flush(rdpPcap* pcap); + +#ifdef __cplusplus +} +#endif + +#endif /* FREERDP_UTILS_PCAP_H */ diff --git a/include/freerdp/utils/pod_arrays.h b/include/freerdp/utils/pod_arrays.h new file mode 100644 index 0000000..ef8667d --- /dev/null +++ b/include/freerdp/utils/pod_arrays.h @@ -0,0 +1,138 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * POD arrays + * + * Copyright 2022 David Fort <contact@hardening-consulting.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. + */ +#ifndef FREERDP_UTILS_POD_ARRAYS_H_ +#define FREERDP_UTILS_POD_ARRAYS_H_ + +#include <winpr/wtypes.h> +#include <winpr/assert.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + +#define POD_ARRAYS_IMPL(T, TLOWER) \ + typedef struct \ + { \ + T* values; \ + size_t nvalues; \ + } Array##T; \ + typedef BOOL Array##T##Cb(T* v, void* data); \ + \ + static INLINE void array_##TLOWER##_init(Array##T* a) \ + { \ + WINPR_ASSERT(a); \ + a->values = NULL; \ + a->nvalues = 0; \ + } \ + \ + static INLINE size_t array_##TLOWER##_size(const Array##T* a) \ + { \ + WINPR_ASSERT(a); \ + return a->nvalues; \ + } \ + \ + static INLINE T* array_##TLOWER##_data(const Array##T* a) \ + { \ + WINPR_ASSERT(a); \ + return a->values; \ + } \ + \ + static INLINE const T* array_##TLOWER##_cdata(const Array##T* a) \ + { \ + WINPR_ASSERT(a); \ + return (const T*)a->values; \ + } \ + \ + static INLINE T array_##TLOWER##_get(const Array##T* a, size_t idx) \ + { \ + WINPR_ASSERT(a); \ + WINPR_ASSERT(a->nvalues > idx); \ + return a->values[idx]; \ + } \ + \ + static INLINE void array_##TLOWER##_set(Array##T* a, size_t idx, T v) \ + { \ + WINPR_ASSERT(a); \ + WINPR_ASSERT(a->nvalues > idx); \ + a->values[idx] = v; \ + } \ + \ + static INLINE BOOL array_##TLOWER##_append(Array##T* a, T v) \ + { \ + WINPR_ASSERT(a); \ + T* tmp = realloc(a->values, sizeof(T) * (a->nvalues + 1)); \ + if (!tmp) \ + return FALSE; \ + \ + tmp[a->nvalues] = v; \ + a->values = tmp; \ + a->nvalues++; \ + return TRUE; \ + } \ + \ + static INLINE BOOL array_##TLOWER##_contains(const Array##T* a, T v) \ + { \ + WINPR_ASSERT(a); \ + \ + for (UINT32 i = 0; i < a->nvalues; i++) \ + { \ + if (memcmp(&a->values[i], &v, sizeof(T)) == 0) \ + return TRUE; \ + } \ + \ + return FALSE; \ + } \ + \ + static INLINE BOOL array_##TLOWER##_foreach(Array##T* a, Array##T##Cb cb, void* data) \ + { \ + WINPR_ASSERT(a); \ + for (size_t i = 0; i < a->nvalues; i++) \ + { \ + if (!cb(&a->values[i], data)) \ + return FALSE; \ + } \ + \ + return TRUE; \ + } \ + \ + static INLINE void array_##TLOWER##_reset(Array##T* a) \ + { \ + WINPR_ASSERT(a); \ + a->nvalues = 0; \ + } \ + \ + static INLINE void array_##TLOWER##_uninit(Array##T* a) \ + { \ + WINPR_ASSERT(a); \ + free(a->values); \ + \ + a->values = NULL; \ + a->nvalues = 0; \ + } + + POD_ARRAYS_IMPL(UINT16, uint16) + POD_ARRAYS_IMPL(UINT32, uint32) + POD_ARRAYS_IMPL(UINT64, uint64) + +#ifdef __cplusplus +} +#endif + +#endif /* FREERDP_UTILS_POD_ARRAYS_H_ */ diff --git a/include/freerdp/utils/profiler.h b/include/freerdp/utils/profiler.h new file mode 100644 index 0000000..29b9e32 --- /dev/null +++ b/include/freerdp/utils/profiler.h @@ -0,0 +1,99 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Profiler Utils + * + * Copyright 2011 Stephen Erisman + * + * 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. + */ + +#ifndef FREERDP_UTILS_PROFILER_H +#define FREERDP_UTILS_PROFILER_H + +#include <freerdp/api.h> +#include <freerdp/utils/stopwatch.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct S_PROFILER PROFILER; + + FREERDP_API PROFILER* profiler_create(const char* name); + FREERDP_API void profiler_free(PROFILER* profiler); + + FREERDP_API void profiler_enter(PROFILER* profiler); + FREERDP_API void profiler_exit(PROFILER* profiler); + + FREERDP_API void profiler_print_header(void); + FREERDP_API void profiler_print(PROFILER* profiler); + FREERDP_API void profiler_print_footer(void); + +#ifdef WITH_PROFILER +#define PROFILER_RENAME(prof, name) \ + do \ + { \ + profiler_free(prof); \ + prof = profiler_create(name); \ + } while (0); +#define PROFILER_DEFINE(prof) PROFILER* prof; +#define PROFILER_CREATE(prof, name) prof = profiler_create(name); +#define PROFILER_FREE(prof) profiler_free(prof); +#define PROFILER_ENTER(prof) profiler_enter(prof); +#define PROFILER_EXIT(prof) profiler_exit(prof); +#define PROFILER_PRINT_HEADER profiler_print_header(); +#define PROFILER_PRINT(prof) profiler_print(prof); +#define PROFILER_PRINT_FOOTER profiler_print_footer(); +#else +#define PROFILER_RENAME(prof, name) \ + do \ + { \ + } while (0); + +#define PROFILER_DEFINE(prof) +#define PROFILER_CREATE(prof, name) \ + do \ + { \ + } while (0); +#define PROFILER_FREE(prof) \ + do \ + { \ + } while (0); +#define PROFILER_ENTER(prof) \ + do \ + { \ + } while (0); +#define PROFILER_EXIT(prof) \ + do \ + { \ + } while (0); +#define PROFILER_PRINT_HEADER \ + do \ + { \ + } while (0); +#define PROFILER_PRINT(prof) \ + do \ + { \ + } while (0); +#define PROFILER_PRINT_FOOTER \ + do \ + { \ + } while (0); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* FREERDP_UTILS_PROFILER_H */ diff --git a/include/freerdp/utils/proxy_utils.h b/include/freerdp/utils/proxy_utils.h new file mode 100644 index 0000000..0bd510e --- /dev/null +++ b/include/freerdp/utils/proxy_utils.h @@ -0,0 +1,37 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * RDP Proxy Utils + * + * Copyright 2016 Armin Novak <armin.novak@gmail.com> + * Copyright 2022 Adrian Vollmer <adrian.vollmer@syss.de> + * + * 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. + */ + +#ifndef FREERDP_PROXY_UTILS_H +#define FREERDP_PROXY_UTILS_H + +#include <freerdp/api.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + FREERDP_API BOOL proxy_parse_uri(rdpSettings* settings, const char* uri_in); + +#ifdef __cplusplus +} +#endif + +#endif /* FREERDP_PROXY_UTILS_H */ diff --git a/include/freerdp/utils/rdpdr_utils.h b/include/freerdp/utils/rdpdr_utils.h new file mode 100644 index 0000000..6e205d5 --- /dev/null +++ b/include/freerdp/utils/rdpdr_utils.h @@ -0,0 +1,72 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * RDPDR utility functions + * + * Copyright 2021 Armin Novak <armin.novak@thincast.com> + * Copyright 2021 Thincast Technologies GmbH + * + * 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. + */ + +#ifndef FREERDP_UTILS_RDPDR_H +#define FREERDP_UTILS_RDPDR_H + +#include <winpr/stream.h> +#include <freerdp/api.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct + { + UINT32 DeviceType; + UINT32 DeviceId; + char PreferredDosName[8]; + UINT32 DeviceDataLength; + BYTE* DeviceData; + } RdpdrDevice; + + typedef struct + { + UINT16 CapabilityType; + UINT16 CapabilityLength; + UINT32 Version; + } RDPDR_CAPABILITY_HEADER; + + FREERDP_API const char* rdpdr_component_string(UINT16 component); + FREERDP_API const char* rdpdr_packetid_string(UINT16 packetid); + FREERDP_API const char* rdpdr_irp_string(UINT32 major); + FREERDP_API const char* rdpdr_cap_type_string(UINT16 capability); + + FREERDP_API LONG scard_log_status_error(const char* tag, const char* what, LONG status); + FREERDP_API const char* scard_get_ioctl_string(UINT32 ioControlCode, BOOL funcName); + + FREERDP_API BOOL rdpdr_write_iocompletion_header(wStream* out, UINT32 DeviceId, + UINT32 CompletionId, UINT32 ioStatus); + + FREERDP_API void rdpdr_dump_received_packet(wLog* log, DWORD lvl, wStream* out, + const char* custom); + FREERDP_API void rdpdr_dump_send_packet(wLog* log, DWORD lvl, wStream* out, const char* custom); + + FREERDP_API UINT rdpdr_read_capset_header(wLog* log, wStream* s, + RDPDR_CAPABILITY_HEADER* header); + FREERDP_API UINT rdpdr_write_capset_header(wLog* log, wStream* s, + const RDPDR_CAPABILITY_HEADER* header); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/freerdp/utils/ringbuffer.h b/include/freerdp/utils/ringbuffer.h new file mode 100644 index 0000000..3de191c --- /dev/null +++ b/include/freerdp/utils/ringbuffer.h @@ -0,0 +1,131 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * + * Copyright 2014 Thincast Technologies GmbH + * Copyright 2014 Hardening <contact@hardening-consulting.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. + */ + +#ifndef FREERDP_UTILS_RINGBUFFER_H +#define FREERDP_UTILS_RINGBUFFER_H + +#include <winpr/wtypes.h> +#include <freerdp/api.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** @brief ring buffer meta data */ + typedef struct + { + size_t initialSize; + size_t freeSize; + size_t size; + size_t readPtr; + size_t writePtr; + BYTE* buffer; + } RingBuffer; + + /** @brief a piece of data in the ring buffer, exactly like a glibc iovec */ + typedef struct + { + size_t size; + const BYTE* data; + } DataChunk; + + /** + * initialise a ringbuffer + * + * @param initialSize the initial capacity of the ringBuffer + * @return if the initialisation was successful + */ + FREERDP_API BOOL ringbuffer_init(RingBuffer* rb, size_t initialSize); + + /** + * destroys internal data used by this ringbuffer + * + * @param ringbuffer A pointer to the ringbuffer + */ + FREERDP_API void ringbuffer_destroy(RingBuffer* ringbuffer); + + /** + * computes the space used in this ringbuffer + * + * @param ringbuffer A pointer to the ringbuffer + * @return the number of bytes stored in that ringbuffer + */ + FREERDP_API size_t ringbuffer_used(const RingBuffer* ringbuffer); + + /** returns the capacity of the ring buffer + * + * @param ringbuffer A pointer to the ringbuffer + * @return the capacity of this ring buffer + */ + FREERDP_API size_t ringbuffer_capacity(const RingBuffer* ringbuffer); + + /** writes some bytes in the ringbuffer, if the data doesn't fit, the ringbuffer + * is resized automatically + * + * @param rb the ringbuffer + * @param ptr a pointer on the data to add + * @param sz the size of the data to add + * @return if the operation was successful, it could fail in case of OOM during realloc() + */ + FREERDP_API BOOL ringbuffer_write(RingBuffer* rb, const BYTE* ptr, size_t sz); + + /** ensures that we have sz bytes available at the write head, and return a pointer + * on the write head + * + * @param rb the ring buffer + * @param sz the size to ensure + * @return a pointer on the write head, or NULL in case of OOM + */ + FREERDP_API BYTE* ringbuffer_ensure_linear_write(RingBuffer* rb, size_t sz); + + /** move ahead the write head in case some byte were written directly by using + * a pointer retrieved via ringbuffer_ensure_linear_write(). This function is + * used to commit the written bytes. The provided size should not exceed the + * size ensured by ringbuffer_ensure_linear_write() + * + * @param rb the ring buffer + * @param sz the number of bytes that have been written + * @return if the operation was successful, FALSE is sz is too big + */ + FREERDP_API BOOL ringbuffer_commit_written_bytes(RingBuffer* rb, size_t sz); + + /** peeks the buffer chunks for sz bytes and returns how many chunks are filled. + * Note that the sum of the resulting chunks may be smaller than sz. + * + * @param rb the ringbuffer + * @param chunks an array of data chunks that will contain data / size of chunks + * @param sz the requested size + * @return the number of chunks used for reading sz bytes + */ + FREERDP_API int ringbuffer_peek(const RingBuffer* rb, DataChunk chunks[2], size_t sz); + + /** move ahead the read head in case some byte were read using ringbuffer_peek() + * This function is used to commit the bytes that were effectively consumed. + * + * @param rb the ring buffer + * @param sz the number of bytes to read + */ + FREERDP_API void ringbuffer_commit_read_bytes(RingBuffer* rb, size_t sz); + +#ifdef __cplusplus +} +#endif + +#endif /* FREERDP_UTILS_RINGBUFFER_H */ diff --git a/include/freerdp/utils/signal.h b/include/freerdp/utils/signal.h new file mode 100644 index 0000000..8a74b81 --- /dev/null +++ b/include/freerdp/utils/signal.h @@ -0,0 +1,63 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Signal handling + * + * Copyright 2011 Shea Levy <shea@shealevy.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. + */ + +#ifndef FREERDP_UTILS_SIGNAL_H +#define FREERDP_UTILS_SIGNAL_H + +#include <freerdp/api.h> +#include <freerdp/types.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef void (*freerdp_signal_handler_t)(int signum, const char* signame, void* context); + + FREERDP_API int freerdp_handle_signals(void); + + /** \brief registers a cleanup handler for non fatal signals. + * + * This allows cleaning up resources like with \b atexit but for signals. + * + * \param context a context for the clenaup handler. + * \param handler the function to call on cleanup. Must not be \b NULL + * + * \return \b TRUE if registered successfully, \b FALSE otherwise. + */ + FREERDP_API BOOL freerdp_add_signal_cleanup_handler(void* context, + freerdp_signal_handler_t handler); + + /** \brief unregisters a cleanup handler for non fatal signals. + * + * This allows removal of a cleanup handler for signals. + * + * \param context a context for the clenaup handler. + * \param handler the function to call on cleanup. Must not be \b NULL + * + * \return \b TRUE if unregistered successfully, \b FALSE otherwise. + */ + FREERDP_API BOOL freerdp_del_signal_cleanup_handler(void* context, + freerdp_signal_handler_t handler); + +#ifdef __cplusplus +} +#endif + +#endif /* FREERDP_UTILS_SIGNAL_H */ diff --git a/include/freerdp/utils/smartcard_call.h b/include/freerdp/utils/smartcard_call.h new file mode 100644 index 0000000..5f6e026 --- /dev/null +++ b/include/freerdp/utils/smartcard_call.h @@ -0,0 +1,65 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Smartcard Device Service Virtual Channel + * + * Copyright 2011 O.S. Systems Software Ltda. + * Copyright 2011 Eduardo Fiss Beloni <beloni@ossystems.com.br> + * Copyright 2015 Thincast Technologies GmbH + * Copyright 2015 DI (FH) Martin Haimberger <martin.haimberger@thincast.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. + */ + +#ifndef FREERDP_CHANNEL_SMARTCARD_CALL_H +#define FREERDP_CHANNEL_SMARTCARD_CALL_H + +#include <winpr/crt.h> +#include <winpr/stream.h> + +#include <freerdp/api.h> +#include <freerdp/settings.h> +#include <freerdp/channels/scard.h> +#include <freerdp/utils/smartcard_operations.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct s_scard_call_context scard_call_context; + + FREERDP_API void smartcard_call_context_free(scard_call_context* ctx); + + WINPR_ATTR_MALLOC(smartcard_call_context_free, 1) + FREERDP_API scard_call_context* smartcard_call_context_new(const rdpSettings* settings); + + FREERDP_API BOOL smartcard_call_context_signal_stop(scard_call_context* ctx, BOOL reset); + FREERDP_API BOOL smartcard_call_context_add(scard_call_context* ctx, const char* name); + FREERDP_API BOOL smartcard_call_cancel_context(scard_call_context* ctx, SCARDCONTEXT context); + FREERDP_API BOOL smartcard_call_cancel_all_context(scard_call_context* ctx); + FREERDP_API BOOL smartcard_call_release_context(scard_call_context* ctx, SCARDCONTEXT context); + FREERDP_API BOOL smartcard_call_is_configured(scard_call_context* ctx); + + FREERDP_API BOOL smarcard_call_set_callbacks(scard_call_context* ctx, void* userdata, + void* (*fn_new)(void*, SCARDCONTEXT), + void (*fn_free)(void*)); + FREERDP_API void* smartcard_call_get_context(scard_call_context* ctx, SCARDCONTEXT hContext); + + FREERDP_API LONG smartcard_irp_device_control_call(scard_call_context* context, wStream* out, + UINT32* pIoStatus, + SMARTCARD_OPERATION* operation); + +#ifdef __cplusplus +} +#endif +#endif /* FREERDP_CHANNEL_SMARTCARD_CALL_H */ diff --git a/include/freerdp/utils/smartcard_operations.h b/include/freerdp/utils/smartcard_operations.h new file mode 100644 index 0000000..cab7fac --- /dev/null +++ b/include/freerdp/utils/smartcard_operations.h @@ -0,0 +1,96 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Smartcard Device Service Virtual Channel + * + * Copyright 2011 O.S. Systems Software Ltda. + * Copyright 2011 Eduardo Fiss Beloni <beloni@ossystems.com.br> + * Copyright 2015 Thincast Technologies GmbH + * Copyright 2015 DI (FH) Martin Haimberger <martin.haimberger@thincast.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. + */ + +#ifndef FREERDP_CHANNEL_SMARTCARD_OPERATIONS_MAIN_H +#define FREERDP_CHANNEL_SMARTCARD_OPERATIONS_MAIN_H + +#include <winpr/crt.h> +#include <winpr/stream.h> +#include <winpr/smartcard.h> + +#include <freerdp/api.h> +#include <freerdp/channels/scard.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + typedef struct + { + union + { + Handles_Call handles; + Long_Call lng; + Context_Call context; + ContextAndStringA_Call contextAndStringA; + ContextAndStringW_Call contextAndStringW; + ContextAndTwoStringA_Call contextAndTwoStringA; + ContextAndTwoStringW_Call contextAndTwoStringW; + EstablishContext_Call establishContext; + ListReaderGroups_Call listReaderGroups; + ListReaders_Call listReaders; + GetStatusChangeA_Call getStatusChangeA; + LocateCardsA_Call locateCardsA; + LocateCardsW_Call locateCardsW; + LocateCards_ATRMask locateCardsATRMask; + LocateCardsByATRA_Call locateCardsByATRA; + LocateCardsByATRW_Call locateCardsByATRW; + GetStatusChangeW_Call getStatusChangeW; + GetReaderIcon_Call getReaderIcon; + GetDeviceTypeId_Call getDeviceTypeId; + Connect_Common_Call connect; + ConnectA_Call connectA; + ConnectW_Call connectW; + Reconnect_Call reconnect; + HCardAndDisposition_Call hCardAndDisposition; + State_Call state; + Status_Call status; + SCardIO_Request scardIO; + Transmit_Call transmit; + GetTransmitCount_Call getTransmitCount; + Control_Call control; + GetAttrib_Call getAttrib; + SetAttrib_Call setAttrib; + ReadCache_Common readCache; + ReadCacheA_Call readCacheA; + ReadCacheW_Call readCacheW; + WriteCache_Common writeCache; + WriteCacheA_Call writeCacheA; + WriteCacheW_Call writeCacheW; + } call; + UINT32 ioControlCode; + UINT32 completionID; + UINT32 deviceID; + SCARDCONTEXT hContext; + SCARDHANDLE hCard; + const char* ioControlCodeName; + } SMARTCARD_OPERATION; + + FREERDP_API LONG smartcard_irp_device_control_decode(wStream* s, UINT32 CompletionId, + UINT32 FileId, + SMARTCARD_OPERATION* operation); + FREERDP_API void smartcard_operation_free(SMARTCARD_OPERATION* op, BOOL allocated); + +#ifdef __cplusplus +} +#endif +#endif /* FREERDP_CHANNEL_SMARTCARD_CLIENT_OPERATIONS_H */ diff --git a/include/freerdp/utils/smartcard_pack.h b/include/freerdp/utils/smartcard_pack.h new file mode 100644 index 0000000..42a4f02 --- /dev/null +++ b/include/freerdp/utils/smartcard_pack.h @@ -0,0 +1,186 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Smart Card Structure Packing + * + * Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * Copyright 2015 Thincast Technologies GmbH + * Copyright 2015 DI (FH) Martin Haimberger <martin.haimberger@thincast.com> + * Copyright 2020 Armin Novak <armin.novak@thincast.com> + * Copyright 2020 Thincast Technologies GmbH + * + * 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. + */ + +#ifndef FREERDP_CHANNEL_SMARTCARD_CLIENT_PACK_H +#define FREERDP_CHANNEL_SMARTCARD_CLIENT_PACK_H + +#include <winpr/crt.h> +#include <winpr/stream.h> +#include <winpr/smartcard.h> + +#include <freerdp/api.h> +#include <freerdp/channels/scard.h> + +#define SMARTCARD_COMMON_TYPE_HEADER_LENGTH 8 +#define SMARTCARD_PRIVATE_TYPE_HEADER_LENGTH 8 + +#ifdef __cplusplus +extern "C" +{ +#endif + + FREERDP_API LONG smartcard_pack_write_size_align(wStream* s, size_t size, UINT32 alignment); + FREERDP_API LONG smartcard_unpack_read_size_align(wStream* s, size_t size, UINT32 alignment); + + FREERDP_API SCARDCONTEXT smartcard_scard_context_native_from_redir(REDIR_SCARDCONTEXT* context); + FREERDP_API void smartcard_scard_context_native_to_redir(REDIR_SCARDCONTEXT* context, + SCARDCONTEXT hContext); + + FREERDP_API SCARDHANDLE smartcard_scard_handle_native_from_redir(REDIR_SCARDHANDLE* handle); + FREERDP_API void smartcard_scard_handle_native_to_redir(REDIR_SCARDHANDLE* handle, + SCARDHANDLE hCard); + + FREERDP_API LONG smartcard_unpack_common_type_header(wStream* s); + FREERDP_API void smartcard_pack_common_type_header(wStream* s); + + FREERDP_API LONG smartcard_unpack_private_type_header(wStream* s); + FREERDP_API void smartcard_pack_private_type_header(wStream* s, UINT32 objectBufferLength); + + FREERDP_API LONG smartcard_unpack_establish_context_call(wStream* s, + EstablishContext_Call* call); + + FREERDP_API LONG smartcard_pack_establish_context_return(wStream* s, + const EstablishContext_Return* ret); + + FREERDP_API LONG smartcard_unpack_context_call(wStream* s, Context_Call* call, + const char* name); + + FREERDP_API void smartcard_trace_long_return(const Long_Return* ret, const char* name); + + FREERDP_API LONG smartcard_unpack_list_reader_groups_call(wStream* s, + ListReaderGroups_Call* call, + BOOL unicode); + + FREERDP_API LONG smartcard_pack_list_reader_groups_return(wStream* s, + const ListReaderGroups_Return* ret, + BOOL unicode); + + FREERDP_API LONG smartcard_unpack_list_readers_call(wStream* s, ListReaders_Call* call, + BOOL unicode); + + FREERDP_API LONG smartcard_pack_list_readers_return(wStream* s, const ListReaders_Return* ret, + BOOL unicode); + + FREERDP_API LONG + smartcard_unpack_context_and_two_strings_a_call(wStream* s, ContextAndTwoStringA_Call* call); + + FREERDP_API LONG + smartcard_unpack_context_and_two_strings_w_call(wStream* s, ContextAndTwoStringW_Call* call); + + FREERDP_API LONG smartcard_unpack_context_and_string_a_call(wStream* s, + ContextAndStringA_Call* call); + + FREERDP_API LONG smartcard_unpack_context_and_string_w_call(wStream* s, + ContextAndStringW_Call* call); + + FREERDP_API LONG smartcard_unpack_locate_cards_a_call(wStream* s, LocateCardsA_Call* call); + + FREERDP_API LONG smartcard_pack_locate_cards_return(wStream* s, const LocateCards_Return* ret); + + FREERDP_API LONG smartcard_unpack_locate_cards_w_call(wStream* s, LocateCardsW_Call* call); + + FREERDP_API LONG smartcard_pack_locate_cards_w_return(wStream* s, const LocateCardsW_Call* ret); + + FREERDP_API LONG smartcard_unpack_connect_a_call(wStream* s, ConnectA_Call* call); + + FREERDP_API LONG smartcard_unpack_connect_w_call(wStream* s, ConnectW_Call* call); + + FREERDP_API LONG smartcard_pack_connect_return(wStream* s, const Connect_Return* ret); + + FREERDP_API LONG smartcard_unpack_reconnect_call(wStream* s, Reconnect_Call* call); + + FREERDP_API LONG smartcard_pack_reconnect_return(wStream* s, const Reconnect_Return* ret); + + FREERDP_API LONG smartcard_unpack_hcard_and_disposition_call(wStream* s, + HCardAndDisposition_Call* call, + const char* name); + + FREERDP_API LONG smartcard_unpack_get_status_change_a_call(wStream* s, + GetStatusChangeA_Call* call); + + FREERDP_API LONG smartcard_unpack_get_status_change_w_call(wStream* s, + GetStatusChangeW_Call* call); + + FREERDP_API LONG smartcard_pack_get_status_change_return(wStream* s, + const GetStatusChange_Return* ret, + BOOL unicode); + + FREERDP_API LONG smartcard_unpack_state_call(wStream* s, State_Call* call); + FREERDP_API LONG smartcard_pack_state_return(wStream* s, const State_Return* ret); + + FREERDP_API LONG smartcard_unpack_status_call(wStream* s, Status_Call* call, BOOL unicode); + + FREERDP_API LONG smartcard_pack_status_return(wStream* s, const Status_Return* ret, + BOOL unicode); + + FREERDP_API LONG smartcard_unpack_get_attrib_call(wStream* s, GetAttrib_Call* call); + + FREERDP_API LONG smartcard_pack_get_attrib_return(wStream* s, const GetAttrib_Return* ret, + DWORD dwAttrId, DWORD cbAttrCallLen); + + FREERDP_API LONG smartcard_unpack_set_attrib_call(wStream* s, SetAttrib_Call* call); + + FREERDP_API LONG smartcard_unpack_control_call(wStream* s, Control_Call* call); + + FREERDP_API LONG smartcard_pack_control_return(wStream* s, const Control_Return* ret); + + FREERDP_API LONG smartcard_unpack_transmit_call(wStream* s, Transmit_Call* call); + + FREERDP_API LONG smartcard_pack_transmit_return(wStream* s, const Transmit_Return* ret); + + FREERDP_API LONG smartcard_unpack_locate_cards_by_atr_a_call(wStream* s, + LocateCardsByATRA_Call* call); + + FREERDP_API LONG smartcard_unpack_locate_cards_by_atr_w_call(wStream* s, + LocateCardsByATRW_Call* call); + + FREERDP_API LONG smartcard_unpack_read_cache_a_call(wStream* s, ReadCacheA_Call* call); + + FREERDP_API LONG smartcard_unpack_read_cache_w_call(wStream* s, ReadCacheW_Call* call); + + FREERDP_API LONG smartcard_pack_read_cache_return(wStream* s, const ReadCache_Return* ret); + + FREERDP_API LONG smartcard_unpack_write_cache_a_call(wStream* s, WriteCacheA_Call* call); + + FREERDP_API LONG smartcard_unpack_write_cache_w_call(wStream* s, WriteCacheW_Call* call); + + FREERDP_API LONG smartcard_unpack_get_transmit_count_call(wStream* s, + GetTransmitCount_Call* call); + FREERDP_API LONG smartcard_pack_get_transmit_count_return(wStream* s, + const GetTransmitCount_Return* call); + + FREERDP_API LONG smartcard_unpack_get_reader_icon_call(wStream* s, GetReaderIcon_Call* call); + FREERDP_API LONG smartcard_pack_get_reader_icon_return(wStream* s, + const GetReaderIcon_Return* ret); + + FREERDP_API LONG smartcard_unpack_get_device_type_id_call(wStream* s, + GetDeviceTypeId_Call* call); + + FREERDP_API LONG smartcard_pack_device_type_id_return(wStream* s, + const GetDeviceTypeId_Return* ret); + +#ifdef __cplusplus +} +#endif + +#endif /* FREERDP_CHANNEL_SMARTCARD_CLIENT_PACK_H */ diff --git a/include/freerdp/utils/smartcardlogon.h b/include/freerdp/utils/smartcardlogon.h new file mode 100644 index 0000000..66e1097 --- /dev/null +++ b/include/freerdp/utils/smartcardlogon.h @@ -0,0 +1,62 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Logging in with smartcards + * + * Copyright 2022 David Fort <contact@hardening-consulting.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. + */ +#ifndef FREERDP_UTILS_SMARTCARDLOGON_H +#define FREERDP_UTILS_SMARTCARDLOGON_H + +#include <freerdp/types.h> +#include <freerdp/settings.h> +#include <freerdp/crypto/certificate.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct SmartcardKeyInfo_st SmartcardKeyInfo; + + typedef struct SmartcardCertInfo_st + { + LPWSTR csp; + LPWSTR reader; + rdpCertificate* certificate; + char* pkinitArgs; + UINT32 slotId; + char* keyName; + WCHAR* containerName; + char* upn; + char* userHint; + char* domainHint; + char* subject; + char* issuer; + BYTE sha1Hash[20]; + SmartcardKeyInfo* key_info; + } SmartcardCertInfo; + + FREERDP_API BOOL smartcard_enumerateCerts(const rdpSettings* settings, + SmartcardCertInfo*** scCerts, size_t* retCount, + BOOL gateway); + FREERDP_API BOOL smartcard_getCert(const rdpContext* context, SmartcardCertInfo** cert, + BOOL gateway); + FREERDP_API void smartcardCertInfo_Free(SmartcardCertInfo* pscCert); + FREERDP_API void smartcardCertList_Free(SmartcardCertInfo** pscCert, size_t count); + +#ifdef __cplusplus +} +#endif +#endif /* FREERDP_UTILS_SMARTCARDLOGON_H */ diff --git a/include/freerdp/utils/stopwatch.h b/include/freerdp/utils/stopwatch.h new file mode 100644 index 0000000..c267250 --- /dev/null +++ b/include/freerdp/utils/stopwatch.h @@ -0,0 +1,54 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Stopwatch Utils + * + * Copyright 2011 Stephen Erisman + * + * 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. + */ + +#ifndef FREERDP_UTILS_STOPWATCH_H +#define FREERDP_UTILS_STOPWATCH_H + +#include <freerdp/api.h> +#include <freerdp/types.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct + { + UINT64 start; + UINT64 end; + UINT64 elapsed; + UINT32 count; + } STOPWATCH; + + FREERDP_API STOPWATCH* stopwatch_create(void); + FREERDP_API void stopwatch_free(STOPWATCH* stopwatch); + + FREERDP_API void stopwatch_start(STOPWATCH* stopwatch); + FREERDP_API void stopwatch_stop(STOPWATCH* stopwatch); + FREERDP_API void stopwatch_reset(STOPWATCH* stopwatch); + + FREERDP_API double stopwatch_get_elapsed_time_in_seconds(STOPWATCH* stopwatch); + FREERDP_API void stopwatch_get_elapsed_time_in_useconds(STOPWATCH* stopwatch, UINT32* sec, + UINT32* usec); + +#ifdef __cplusplus +} +#endif + +#endif /* FREERDP_UTILS_STOPWATCH_H */ diff --git a/include/freerdp/utils/string.h b/include/freerdp/utils/string.h new file mode 100644 index 0000000..c008368 --- /dev/null +++ b/include/freerdp/utils/string.h @@ -0,0 +1,40 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * + * String Utils - Helper functions converting something to string + * + * Copyright 2022 Armin Novak <armin.novak@thincast.com> + * Copyright 2022 Thincast Technologies GmbH + * + * 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. + */ + +#ifndef FREERDP_UTILS_STRING_H +#define FREERDP_UTILS_STRING_H + +#include <freerdp/api.h> +#include <freerdp/types.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + FREERDP_API char* rdp_redirection_flags_to_string(UINT32 flags, char* buffer, size_t size); + FREERDP_API char* rdp_cluster_info_flags_to_string(UINT32 flags, char* buffer, size_t size); + +#ifdef __cplusplus +} +#endif + +#endif /* FREERDP_UTILS_STRING_H */ |