2012-11-18 07:03:04 +04:00
|
|
|
/**
|
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
|
|
|
* Addin Loader
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2022-02-16 13:20:38 +03:00
|
|
|
#include <freerdp/config.h>
|
2012-11-18 07:03:04 +04:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <winpr/crt.h>
|
|
|
|
#include <winpr/path.h>
|
2018-08-24 10:54:25 +03:00
|
|
|
#include <winpr/string.h>
|
2012-11-18 07:03:04 +04:00
|
|
|
#include <winpr/library.h>
|
|
|
|
|
|
|
|
#include <freerdp/addin.h>
|
2015-11-05 16:02:07 +03:00
|
|
|
#include <freerdp/build-config.h>
|
2012-11-18 07:03:04 +04:00
|
|
|
|
2016-10-27 15:41:05 +03:00
|
|
|
#include <freerdp/log.h>
|
|
|
|
#define TAG FREERDP_TAG("addin")
|
2012-11-18 07:03:04 +04:00
|
|
|
|
2016-11-10 12:18:55 +03:00
|
|
|
static INLINE BOOL is_path_required(LPCSTR path, size_t len)
|
|
|
|
{
|
|
|
|
if (!path || (len <= 1))
|
|
|
|
return FALSE;
|
2017-04-10 11:38:38 +03:00
|
|
|
|
2016-11-10 12:18:55 +03:00
|
|
|
if (strcmp(path, ".") == 0)
|
|
|
|
return FALSE;
|
2017-04-10 11:38:38 +03:00
|
|
|
|
2016-11-10 12:18:55 +03:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2016-10-07 15:06:46 +03:00
|
|
|
LPSTR freerdp_get_library_install_path(void)
|
2012-11-18 07:03:04 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
LPSTR pszPath = NULL;
|
|
|
|
size_t cchPath = 0;
|
|
|
|
size_t cchLibraryPath = 0;
|
|
|
|
size_t cchInstallPrefix = 0;
|
|
|
|
BOOL needLibPath = 0;
|
|
|
|
BOOL needInstallPath = 0;
|
2012-12-20 16:09:33 +04:00
|
|
|
LPCSTR pszLibraryPath = FREERDP_LIBRARY_PATH;
|
|
|
|
LPCSTR pszInstallPrefix = FREERDP_INSTALL_PREFIX;
|
2016-11-10 12:18:55 +03:00
|
|
|
cchLibraryPath = strlen(pszLibraryPath) + 1;
|
|
|
|
cchInstallPrefix = strlen(pszInstallPrefix) + 1;
|
|
|
|
cchPath = cchInstallPrefix + cchLibraryPath;
|
|
|
|
needInstallPath = is_path_required(pszInstallPrefix, cchInstallPrefix);
|
|
|
|
needLibPath = is_path_required(pszLibraryPath, cchLibraryPath);
|
|
|
|
|
|
|
|
if (!needInstallPath && !needLibPath)
|
|
|
|
return NULL;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
pszPath = (LPSTR)malloc(cchPath + 1);
|
2016-10-07 15:06:46 +03:00
|
|
|
|
2015-06-16 16:42:07 +03:00
|
|
|
if (!pszPath)
|
|
|
|
return NULL;
|
2012-11-18 07:03:04 +04:00
|
|
|
|
2016-11-10 12:18:55 +03:00
|
|
|
if (needInstallPath)
|
|
|
|
{
|
|
|
|
CopyMemory(pszPath, pszInstallPrefix, cchInstallPrefix);
|
|
|
|
pszPath[cchInstallPrefix] = '\0';
|
|
|
|
}
|
2012-11-18 07:03:04 +04:00
|
|
|
|
2016-11-10 12:18:55 +03:00
|
|
|
if (needLibPath)
|
2015-06-16 16:42:07 +03:00
|
|
|
{
|
2016-11-10 12:18:55 +03:00
|
|
|
if (FAILED(NativePathCchAppendA(pszPath, cchPath + 1, pszLibraryPath)))
|
|
|
|
{
|
|
|
|
free(pszPath);
|
|
|
|
return NULL;
|
|
|
|
}
|
2015-06-16 16:42:07 +03:00
|
|
|
}
|
2012-11-18 07:03:04 +04:00
|
|
|
|
|
|
|
return pszPath;
|
|
|
|
}
|
|
|
|
|
2016-10-07 15:06:46 +03:00
|
|
|
LPSTR freerdp_get_dynamic_addin_install_path(void)
|
2012-11-18 07:03:04 +04:00
|
|
|
{
|
2021-11-04 10:59:38 +03:00
|
|
|
#if defined(WITH_ADD_PLUGIN_TO_RPATH)
|
|
|
|
return NULL;
|
|
|
|
#else
|
2024-01-23 18:49:54 +03:00
|
|
|
LPSTR pszPath = NULL;
|
|
|
|
size_t cchPath = 0;
|
|
|
|
size_t cchAddinPath = 0;
|
|
|
|
size_t cchInstallPrefix = 0;
|
|
|
|
BOOL needLibPath = 0;
|
|
|
|
BOOL needInstallPath = 0;
|
2012-12-20 16:09:33 +04:00
|
|
|
LPCSTR pszAddinPath = FREERDP_ADDIN_PATH;
|
|
|
|
LPCSTR pszInstallPrefix = FREERDP_INSTALL_PREFIX;
|
2016-11-10 12:18:55 +03:00
|
|
|
cchAddinPath = strlen(pszAddinPath) + 1;
|
|
|
|
cchInstallPrefix = strlen(pszInstallPrefix) + 1;
|
|
|
|
cchPath = cchInstallPrefix + cchAddinPath;
|
|
|
|
needInstallPath = is_path_required(pszInstallPrefix, cchInstallPrefix);
|
|
|
|
needLibPath = is_path_required(pszAddinPath, cchAddinPath);
|
|
|
|
|
2022-06-23 08:57:38 +03:00
|
|
|
WLog_DBG(TAG,
|
|
|
|
"freerdp_get_dynamic_addin_install_path <- pszInstallPrefix: %s, pszAddinPath: %s",
|
|
|
|
pszInstallPrefix, pszAddinPath);
|
2021-10-03 11:57:43 +03:00
|
|
|
|
2016-11-10 12:18:55 +03:00
|
|
|
if (!needInstallPath && !needLibPath)
|
|
|
|
return NULL;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
pszPath = (LPSTR)calloc(cchPath + 1, sizeof(CHAR));
|
2016-10-07 15:06:46 +03:00
|
|
|
|
2015-06-17 23:08:02 +03:00
|
|
|
if (!pszPath)
|
|
|
|
return NULL;
|
2012-11-18 07:03:04 +04:00
|
|
|
|
2016-11-10 12:18:55 +03:00
|
|
|
if (needInstallPath)
|
|
|
|
{
|
|
|
|
CopyMemory(pszPath, pszInstallPrefix, cchInstallPrefix);
|
|
|
|
pszPath[cchInstallPrefix] = '\0';
|
|
|
|
}
|
2012-11-18 07:03:04 +04:00
|
|
|
|
2016-11-10 12:18:55 +03:00
|
|
|
if (needLibPath)
|
2015-06-16 16:42:07 +03:00
|
|
|
{
|
2016-11-10 12:18:55 +03:00
|
|
|
if (FAILED(NativePathCchAppendA(pszPath, cchPath + 1, pszAddinPath)))
|
|
|
|
{
|
|
|
|
free(pszPath);
|
|
|
|
return NULL;
|
|
|
|
}
|
2015-06-16 16:42:07 +03:00
|
|
|
}
|
2012-11-18 07:03:04 +04:00
|
|
|
|
2021-10-03 11:57:43 +03:00
|
|
|
WLog_DBG(TAG, "freerdp_get_dynamic_addin_install_path -> pszPath: %s", pszPath);
|
|
|
|
|
2012-11-18 07:03:04 +04:00
|
|
|
return pszPath;
|
2021-11-04 10:59:38 +03:00
|
|
|
#endif
|
2012-11-18 07:03:04 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
PVIRTUALCHANNELENTRY freerdp_load_dynamic_addin(LPCSTR pszFileName, LPCSTR pszPath,
|
|
|
|
LPCSTR pszEntryName)
|
2012-11-18 07:03:04 +04:00
|
|
|
{
|
2016-11-10 12:18:55 +03:00
|
|
|
LPSTR pszAddinInstallPath = freerdp_get_dynamic_addin_install_path();
|
|
|
|
PVIRTUALCHANNELENTRY entry = NULL;
|
|
|
|
BOOL bHasExt = TRUE;
|
2024-01-23 18:49:54 +03:00
|
|
|
PCSTR pszExt = NULL;
|
2016-11-10 12:18:55 +03:00
|
|
|
size_t cchExt = 0;
|
|
|
|
HINSTANCE library = NULL;
|
2024-01-23 18:49:54 +03:00
|
|
|
size_t cchFileName = 0;
|
|
|
|
size_t cchFilePath = 0;
|
2016-12-01 13:50:01 +03:00
|
|
|
LPSTR pszAddinFile = NULL;
|
2016-11-10 12:18:55 +03:00
|
|
|
LPSTR pszFilePath = NULL;
|
|
|
|
LPSTR pszRelativeFilePath = NULL;
|
2024-01-23 18:49:54 +03:00
|
|
|
size_t cchAddinFile = 0;
|
|
|
|
size_t cchAddinInstallPath = 0;
|
2016-11-10 12:18:55 +03:00
|
|
|
|
|
|
|
if (!pszFileName || !pszEntryName)
|
|
|
|
goto fail;
|
|
|
|
|
2022-06-23 08:57:38 +03:00
|
|
|
WLog_DBG(TAG, "freerdp_load_dynamic_addin <- pszFileName: %s, pszPath: %s, pszEntryName: %s",
|
|
|
|
pszFileName, pszPath, pszEntryName);
|
2021-10-03 11:57:43 +03:00
|
|
|
|
2012-11-18 07:03:04 +04:00
|
|
|
cchFileName = strlen(pszFileName);
|
|
|
|
|
2016-11-10 12:18:55 +03:00
|
|
|
/* Get file name with prefix and extension */
|
2015-06-22 19:52:13 +03:00
|
|
|
if (FAILED(PathCchFindExtensionA(pszFileName, cchFileName + 1, &pszExt)))
|
2012-11-18 07:03:04 +04:00
|
|
|
{
|
|
|
|
pszExt = PathGetSharedLibraryExtensionA(PATH_SHARED_LIB_EXT_WITH_DOT);
|
|
|
|
cchExt = strlen(pszExt);
|
|
|
|
bHasExt = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bHasExt)
|
|
|
|
{
|
|
|
|
pszAddinFile = _strdup(pszFileName);
|
2016-10-07 15:06:46 +03:00
|
|
|
|
2015-06-17 23:08:02 +03:00
|
|
|
if (!pszAddinFile)
|
2016-11-10 12:18:55 +03:00
|
|
|
goto fail;
|
2012-11-18 07:03:04 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-11-05 16:02:07 +03:00
|
|
|
cchAddinFile = cchFileName + cchExt + 2 + sizeof(FREERDP_SHARED_LIBRARY_PREFIX);
|
2019-11-06 17:24:51 +03:00
|
|
|
pszAddinFile = (LPSTR)malloc(cchAddinFile + 1);
|
2016-10-07 15:06:46 +03:00
|
|
|
|
2015-06-17 23:08:02 +03:00
|
|
|
if (!pszAddinFile)
|
2016-11-10 12:18:55 +03:00
|
|
|
goto fail;
|
2016-10-07 15:06:46 +03:00
|
|
|
|
2024-08-26 16:39:33 +03:00
|
|
|
(void)sprintf_s(pszAddinFile, cchAddinFile, FREERDP_SHARED_LIBRARY_PREFIX "%s%s",
|
|
|
|
pszFileName, pszExt);
|
2012-11-18 07:03:04 +04:00
|
|
|
}
|
2017-04-10 11:38:38 +03:00
|
|
|
|
2016-11-10 12:18:55 +03:00
|
|
|
cchAddinFile = strlen(pszAddinFile);
|
|
|
|
|
|
|
|
/* If a path is provided prefix the library name with it. */
|
|
|
|
if (pszPath)
|
|
|
|
{
|
|
|
|
size_t relPathLen = strlen(pszPath) + cchAddinFile + 1;
|
|
|
|
pszRelativeFilePath = calloc(relPathLen, sizeof(CHAR));
|
2017-04-10 11:38:38 +03:00
|
|
|
|
2016-11-10 12:18:55 +03:00
|
|
|
if (!pszRelativeFilePath)
|
|
|
|
goto fail;
|
2017-04-10 11:38:38 +03:00
|
|
|
|
2024-08-26 16:39:33 +03:00
|
|
|
(void)sprintf_s(pszRelativeFilePath, relPathLen, "%s", pszPath);
|
2023-07-26 11:33:30 +03:00
|
|
|
const HRESULT hr = NativePathCchAppendA(pszRelativeFilePath, relPathLen, pszAddinFile);
|
|
|
|
if (FAILED(hr))
|
|
|
|
goto fail;
|
2016-11-10 12:18:55 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
pszRelativeFilePath = _strdup(pszAddinFile);
|
|
|
|
|
|
|
|
if (!pszRelativeFilePath)
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
/* If a system prefix path is provided try these locations too. */
|
|
|
|
if (pszAddinInstallPath)
|
|
|
|
{
|
|
|
|
cchAddinInstallPath = strlen(pszAddinInstallPath);
|
|
|
|
cchFilePath = cchAddinInstallPath + cchFileName + 32;
|
2019-11-06 17:24:51 +03:00
|
|
|
pszFilePath = (LPSTR)malloc(cchFilePath + 1);
|
2016-11-10 12:18:55 +03:00
|
|
|
|
|
|
|
if (!pszFilePath)
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
CopyMemory(pszFilePath, pszAddinInstallPath, cchAddinInstallPath);
|
|
|
|
pszFilePath[cchAddinInstallPath] = '\0';
|
2024-08-29 12:11:11 +03:00
|
|
|
const HRESULT hr = NativePathCchAppendA(pszFilePath, cchFilePath + 1, pszRelativeFilePath);
|
2023-07-26 11:33:30 +03:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto fail;
|
2016-11-10 12:18:55 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
pszFilePath = _strdup(pszRelativeFilePath);
|
2012-11-18 07:03:04 +04:00
|
|
|
|
2021-08-25 17:34:35 +03:00
|
|
|
library = LoadLibraryX(pszFilePath);
|
2012-11-19 02:32:18 +04:00
|
|
|
|
2012-11-18 07:03:04 +04:00
|
|
|
if (!library)
|
2016-11-10 12:18:55 +03:00
|
|
|
goto fail;
|
2012-11-18 07:03:04 +04:00
|
|
|
|
2024-09-04 20:02:51 +03:00
|
|
|
entry = GetProcAddressAs(library, pszEntryName, PVIRTUALCHANNELENTRY);
|
2016-11-10 12:18:55 +03:00
|
|
|
fail:
|
|
|
|
free(pszRelativeFilePath);
|
|
|
|
free(pszAddinFile);
|
|
|
|
free(pszFilePath);
|
|
|
|
free(pszAddinInstallPath);
|
2017-04-10 11:38:38 +03:00
|
|
|
|
2016-11-10 12:18:55 +03:00
|
|
|
if (!entry && library)
|
|
|
|
FreeLibrary(library);
|
2017-04-10 11:38:38 +03:00
|
|
|
|
2012-11-18 07:03:04 +04:00
|
|
|
return entry;
|
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
PVIRTUALCHANNELENTRY freerdp_load_dynamic_channel_addin_entry(LPCSTR pszName, LPCSTR pszSubsystem,
|
|
|
|
LPCSTR pszType, DWORD dwFlags)
|
2012-11-18 07:03:04 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
PVIRTUALCHANNELENTRY entry = NULL;
|
|
|
|
LPSTR pszFileName = NULL;
|
2017-12-21 13:34:44 +03:00
|
|
|
const size_t cchBaseFileName = sizeof(FREERDP_SHARED_LIBRARY_PREFIX) + 32;
|
2019-11-07 09:41:48 +03:00
|
|
|
size_t nameLen = 0;
|
|
|
|
size_t subsystemLen = 0;
|
|
|
|
size_t typeLen = 0;
|
2021-11-04 10:59:38 +03:00
|
|
|
size_t cchFileName = 0;
|
|
|
|
|
2019-11-07 09:41:48 +03:00
|
|
|
if (pszName)
|
|
|
|
nameLen = strnlen(pszName, MAX_PATH);
|
|
|
|
if (pszSubsystem)
|
|
|
|
subsystemLen = strnlen(pszSubsystem, MAX_PATH);
|
|
|
|
if (pszType)
|
|
|
|
typeLen = strnlen(pszType, MAX_PATH);
|
2012-11-18 07:03:04 +04:00
|
|
|
|
|
|
|
if (pszName && pszSubsystem && pszType)
|
|
|
|
{
|
2022-06-23 08:57:38 +03:00
|
|
|
cchFileName = cchBaseFileName + nameLen + subsystemLen + typeLen;
|
2019-11-06 17:24:51 +03:00
|
|
|
pszFileName = (LPSTR)malloc(cchFileName);
|
2016-10-07 15:06:46 +03:00
|
|
|
|
2015-06-16 16:42:07 +03:00
|
|
|
if (!pszFileName)
|
|
|
|
return NULL;
|
2016-10-07 15:06:46 +03:00
|
|
|
|
2024-08-26 16:39:33 +03:00
|
|
|
(void)sprintf_s(pszFileName, cchFileName, "%s-client-%s-%s", pszName, pszSubsystem,
|
|
|
|
pszType);
|
2012-11-18 07:03:04 +04:00
|
|
|
}
|
|
|
|
else if (pszName && pszSubsystem)
|
|
|
|
{
|
2021-11-04 10:59:38 +03:00
|
|
|
cchFileName = cchBaseFileName + nameLen + subsystemLen;
|
2019-11-06 17:24:51 +03:00
|
|
|
pszFileName = (LPSTR)malloc(cchFileName);
|
2016-10-07 15:06:46 +03:00
|
|
|
|
2015-06-16 16:42:07 +03:00
|
|
|
if (!pszFileName)
|
|
|
|
return NULL;
|
|
|
|
|
2024-08-26 16:39:33 +03:00
|
|
|
(void)sprintf_s(pszFileName, cchFileName, "%s-client-%s", pszName, pszSubsystem);
|
2012-11-18 07:03:04 +04:00
|
|
|
}
|
|
|
|
else if (pszName)
|
|
|
|
{
|
2022-06-23 08:57:38 +03:00
|
|
|
cchFileName = cchBaseFileName + nameLen;
|
2019-11-06 17:24:51 +03:00
|
|
|
pszFileName = (LPSTR)malloc(cchFileName);
|
2016-10-07 15:06:46 +03:00
|
|
|
|
2015-06-16 16:42:07 +03:00
|
|
|
if (!pszFileName)
|
|
|
|
return NULL;
|
|
|
|
|
2024-08-26 16:39:33 +03:00
|
|
|
(void)sprintf_s(pszFileName, cchFileName, "%s-client", pszName);
|
2012-11-18 07:03:04 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2021-11-04 10:59:38 +03:00
|
|
|
{
|
|
|
|
LPCSTR pszExtension = PathGetSharedLibraryExtensionA(0);
|
2023-12-13 12:11:11 +03:00
|
|
|
const char pszPrefix[] = FREERDP_SHARED_LIBRARY_PREFIX;
|
2022-04-28 11:49:42 +03:00
|
|
|
int rc = 0;
|
2021-11-04 10:59:38 +03:00
|
|
|
|
2023-12-13 12:39:15 +03:00
|
|
|
cchFileName += strnlen(pszPrefix, ARRAYSIZE(pszPrefix));
|
2021-11-04 10:59:38 +03:00
|
|
|
if (pszExtension)
|
|
|
|
cchFileName += strnlen(pszExtension, MAX_PATH) + 1;
|
2023-06-05 13:16:57 +03:00
|
|
|
LPSTR tmp = calloc(cchFileName, sizeof(CHAR));
|
2021-11-04 10:59:38 +03:00
|
|
|
if (tmp)
|
|
|
|
rc = sprintf_s(tmp, cchFileName, "%s%s.%s", pszPrefix, pszFileName, pszExtension);
|
2022-04-28 11:49:42 +03:00
|
|
|
|
2021-11-04 10:59:38 +03:00
|
|
|
free(pszFileName);
|
|
|
|
pszFileName = tmp;
|
2022-04-28 11:49:42 +03:00
|
|
|
if (!pszFileName || (rc < 0))
|
|
|
|
{
|
|
|
|
free(pszFileName);
|
2021-11-04 10:59:38 +03:00
|
|
|
return NULL;
|
2022-04-28 11:49:42 +03:00
|
|
|
}
|
2021-11-04 10:59:38 +03:00
|
|
|
}
|
|
|
|
|
2012-11-18 07:03:04 +04:00
|
|
|
if (pszSubsystem)
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
LPSTR pszEntryName = NULL;
|
|
|
|
size_t cchEntryName = 0;
|
2012-11-18 07:03:04 +04:00
|
|
|
/* subsystem add-in */
|
2019-10-29 12:18:09 +03:00
|
|
|
cchEntryName = 64 + nameLen;
|
2019-11-06 17:24:51 +03:00
|
|
|
pszEntryName = (LPSTR)malloc(cchEntryName + 1);
|
2016-10-07 15:06:46 +03:00
|
|
|
|
2015-06-16 16:42:07 +03:00
|
|
|
if (!pszEntryName)
|
|
|
|
{
|
|
|
|
free(pszFileName);
|
|
|
|
return NULL;
|
|
|
|
}
|
2012-11-18 07:03:04 +04:00
|
|
|
|
2024-08-26 16:39:33 +03:00
|
|
|
(void)sprintf_s(pszEntryName, cchEntryName + 1, "freerdp_%s_client_subsystem_entry",
|
|
|
|
pszName);
|
2012-11-18 07:03:04 +04:00
|
|
|
entry = freerdp_load_dynamic_addin(pszFileName, NULL, pszEntryName);
|
2012-11-19 22:26:56 +04:00
|
|
|
free(pszEntryName);
|
|
|
|
free(pszFileName);
|
2015-06-16 16:42:07 +03:00
|
|
|
return entry;
|
2012-11-18 07:03:04 +04:00
|
|
|
}
|
|
|
|
|
2015-06-16 16:42:07 +03:00
|
|
|
/* channel add-in */
|
2012-11-19 22:26:56 +04:00
|
|
|
|
2015-06-16 16:42:07 +03:00
|
|
|
if (dwFlags & FREERDP_ADDIN_CHANNEL_STATIC)
|
2016-12-28 13:21:14 +03:00
|
|
|
{
|
|
|
|
if (dwFlags & FREERDP_ADDIN_CHANNEL_ENTRYEX)
|
|
|
|
entry = freerdp_load_dynamic_addin(pszFileName, NULL, "VirtualChannelEntryEx");
|
|
|
|
else
|
|
|
|
entry = freerdp_load_dynamic_addin(pszFileName, NULL, "VirtualChannelEntry");
|
|
|
|
}
|
2015-06-16 16:42:07 +03:00
|
|
|
else if (dwFlags & FREERDP_ADDIN_CHANNEL_DYNAMIC)
|
|
|
|
entry = freerdp_load_dynamic_addin(pszFileName, NULL, "DVCPluginEntry");
|
|
|
|
else if (dwFlags & FREERDP_ADDIN_CHANNEL_DEVICE)
|
|
|
|
entry = freerdp_load_dynamic_addin(pszFileName, NULL, "DeviceServiceEntry");
|
|
|
|
else
|
|
|
|
entry = freerdp_load_dynamic_addin(pszFileName, NULL, pszType);
|
2012-11-18 07:03:04 +04:00
|
|
|
|
2015-06-16 16:42:07 +03:00
|
|
|
free(pszFileName);
|
|
|
|
return entry;
|
2012-11-18 07:03:04 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static FREERDP_LOAD_CHANNEL_ADDIN_ENTRY_FN freerdp_load_static_channel_addin_entry = NULL;
|
2012-11-18 07:03:04 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
int freerdp_register_addin_provider(FREERDP_LOAD_CHANNEL_ADDIN_ENTRY_FN provider, DWORD dwFlags)
|
2012-11-18 07:03:04 +04:00
|
|
|
{
|
|
|
|
freerdp_load_static_channel_addin_entry = provider;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-06-22 13:16:41 +03:00
|
|
|
FREERDP_LOAD_CHANNEL_ADDIN_ENTRY_FN freerdp_get_current_addin_provider(void)
|
|
|
|
{
|
|
|
|
return freerdp_load_static_channel_addin_entry;
|
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
PVIRTUALCHANNELENTRY freerdp_load_channel_addin_entry(LPCSTR pszName, LPCSTR pszSubsystem,
|
|
|
|
LPCSTR pszType, DWORD dwFlags)
|
2012-11-18 07:03:04 +04:00
|
|
|
{
|
2016-10-07 15:06:46 +03:00
|
|
|
PVIRTUALCHANNELENTRY entry = NULL;
|
2012-11-18 07:03:04 +04:00
|
|
|
|
|
|
|
if (freerdp_load_static_channel_addin_entry)
|
2016-11-16 17:52:24 +03:00
|
|
|
entry = freerdp_load_static_channel_addin_entry(pszName, pszSubsystem, pszType, dwFlags);
|
|
|
|
|
2012-11-18 07:03:04 +04:00
|
|
|
if (!entry)
|
2016-11-16 17:52:24 +03:00
|
|
|
entry = freerdp_load_dynamic_channel_addin_entry(pszName, pszSubsystem, pszType, dwFlags);
|
2012-11-18 07:03:04 +04:00
|
|
|
|
2016-10-27 15:41:05 +03:00
|
|
|
if (!entry)
|
|
|
|
WLog_WARN(TAG, "Failed to load channel %s [%s]", pszName, pszSubsystem);
|
|
|
|
|
2012-11-18 07:03:04 +04:00
|
|
|
return entry;
|
|
|
|
}
|