Addin loader using proper function pointer defines.
This commit is contained in:
parent
943e295714
commit
14fcfbbf31
@ -750,7 +750,7 @@ static char** freerdp_command_line_parse_comma_separated_values_offset(
|
|||||||
|
|
||||||
p = t;
|
p = t;
|
||||||
|
|
||||||
if (count > 0)
|
if (count)
|
||||||
MoveMemory(&p[1], p, sizeof(char*)** count);
|
MoveMemory(&p[1], p, sizeof(char*)** count);
|
||||||
|
|
||||||
(*count)++;
|
(*count)++;
|
||||||
@ -2506,7 +2506,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
|||||||
static BOOL freerdp_client_load_static_channel_addin(rdpChannels* channels,
|
static BOOL freerdp_client_load_static_channel_addin(rdpChannels* channels,
|
||||||
rdpSettings* settings, char* name, void* data)
|
rdpSettings* settings, char* name, void* data)
|
||||||
{
|
{
|
||||||
void* entry;
|
PVIRTUALCHANNELENTRY entry;
|
||||||
entry = freerdp_load_channel_addin_entry(name, NULL, NULL,
|
entry = freerdp_load_channel_addin_entry(name, NULL, NULL,
|
||||||
FREERDP_ADDIN_CHANNEL_STATIC);
|
FREERDP_ADDIN_CHANNEL_STATIC);
|
||||||
|
|
||||||
|
@ -46,7 +46,8 @@ struct _FREERDP_ADDIN
|
|||||||
};
|
};
|
||||||
typedef struct _FREERDP_ADDIN FREERDP_ADDIN;
|
typedef struct _FREERDP_ADDIN FREERDP_ADDIN;
|
||||||
|
|
||||||
typedef void* (*FREERDP_LOAD_CHANNEL_ADDIN_ENTRY_FN)(LPCSTR pszName, LPSTR pszSubsystem, LPSTR pszType, DWORD dwFlags);
|
typedef PVIRTUALCHANNELENTRY(*FREERDP_LOAD_CHANNEL_ADDIN_ENTRY_FN)(
|
||||||
|
LPCSTR pszName, LPSTR pszSubsystem, LPSTR pszType, DWORD dwFlags);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -55,11 +56,15 @@ extern "C" {
|
|||||||
FREERDP_API LPSTR freerdp_get_library_install_path(void);
|
FREERDP_API LPSTR freerdp_get_library_install_path(void);
|
||||||
FREERDP_API LPSTR freerdp_get_dynamic_addin_install_path(void);
|
FREERDP_API LPSTR freerdp_get_dynamic_addin_install_path(void);
|
||||||
|
|
||||||
FREERDP_API int freerdp_register_addin_provider(FREERDP_LOAD_CHANNEL_ADDIN_ENTRY_FN provider, DWORD dwFlags);
|
FREERDP_API int freerdp_register_addin_provider(
|
||||||
|
FREERDP_LOAD_CHANNEL_ADDIN_ENTRY_FN provider, DWORD dwFlags);
|
||||||
|
|
||||||
FREERDP_API void* freerdp_load_dynamic_addin(LPCSTR pszFileName, LPCSTR pszPath, LPCSTR pszEntryName);
|
FREERDP_API PVIRTUALCHANNELENTRY freerdp_load_dynamic_addin(LPCSTR pszFileName,
|
||||||
FREERDP_API void* freerdp_load_dynamic_channel_addin_entry(LPCSTR pszName, LPSTR pszSubsystem, LPSTR pszType, DWORD dwFlags);
|
LPCSTR pszPath, LPCSTR pszEntryName);
|
||||||
FREERDP_API void* freerdp_load_channel_addin_entry(LPCSTR pszName, LPSTR pszSubsystem, LPSTR pszType, DWORD dwFlags);
|
FREERDP_API PVIRTUALCHANNELENTRY freerdp_load_dynamic_channel_addin_entry(
|
||||||
|
LPCSTR pszName, LPSTR pszSubsystem, LPSTR pszType, DWORD dwFlags);
|
||||||
|
FREERDP_API PVIRTUALCHANNELENTRY freerdp_load_channel_addin_entry(
|
||||||
|
LPCSTR pszName, LPSTR pszSubsystem, LPSTR pszType, DWORD dwFlags);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
#include <freerdp/build-config.h>
|
#include <freerdp/build-config.h>
|
||||||
|
|
||||||
|
|
||||||
LPSTR freerdp_get_library_install_path()
|
LPSTR freerdp_get_library_install_path(void)
|
||||||
{
|
{
|
||||||
LPSTR pszPath;
|
LPSTR pszPath;
|
||||||
size_t cchPath;
|
size_t cchPath;
|
||||||
@ -41,12 +41,11 @@ LPSTR freerdp_get_library_install_path()
|
|||||||
size_t cchInstallPrefix;
|
size_t cchInstallPrefix;
|
||||||
LPCSTR pszLibraryPath = FREERDP_LIBRARY_PATH;
|
LPCSTR pszLibraryPath = FREERDP_LIBRARY_PATH;
|
||||||
LPCSTR pszInstallPrefix = FREERDP_INSTALL_PREFIX;
|
LPCSTR pszInstallPrefix = FREERDP_INSTALL_PREFIX;
|
||||||
|
|
||||||
cchLibraryPath = strlen(pszLibraryPath);
|
cchLibraryPath = strlen(pszLibraryPath);
|
||||||
cchInstallPrefix = strlen(pszInstallPrefix);
|
cchInstallPrefix = strlen(pszInstallPrefix);
|
||||||
|
|
||||||
cchPath = cchInstallPrefix + cchLibraryPath + 2;
|
cchPath = cchInstallPrefix + cchLibraryPath + 2;
|
||||||
pszPath = (LPSTR) malloc(cchPath + 1);
|
pszPath = (LPSTR) malloc(cchPath + 1);
|
||||||
|
|
||||||
if (!pszPath)
|
if (!pszPath)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -62,7 +61,7 @@ LPSTR freerdp_get_library_install_path()
|
|||||||
return pszPath;
|
return pszPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
LPSTR freerdp_get_dynamic_addin_install_path()
|
LPSTR freerdp_get_dynamic_addin_install_path(void)
|
||||||
{
|
{
|
||||||
LPSTR pszPath;
|
LPSTR pszPath;
|
||||||
size_t cchPath;
|
size_t cchPath;
|
||||||
@ -70,12 +69,11 @@ LPSTR freerdp_get_dynamic_addin_install_path()
|
|||||||
size_t cchInstallPrefix;
|
size_t cchInstallPrefix;
|
||||||
LPCSTR pszAddinPath = FREERDP_ADDIN_PATH;
|
LPCSTR pszAddinPath = FREERDP_ADDIN_PATH;
|
||||||
LPCSTR pszInstallPrefix = FREERDP_INSTALL_PREFIX;
|
LPCSTR pszInstallPrefix = FREERDP_INSTALL_PREFIX;
|
||||||
|
|
||||||
cchAddinPath = strlen(pszAddinPath);
|
cchAddinPath = strlen(pszAddinPath);
|
||||||
cchInstallPrefix = strlen(pszInstallPrefix);
|
cchInstallPrefix = strlen(pszInstallPrefix);
|
||||||
|
|
||||||
cchPath = cchInstallPrefix + cchAddinPath + 2;
|
cchPath = cchInstallPrefix + cchAddinPath + 2;
|
||||||
pszPath = (LPSTR) malloc(cchPath + 1);
|
pszPath = (LPSTR) malloc(cchPath + 1);
|
||||||
|
|
||||||
if (!pszPath)
|
if (!pszPath)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -91,9 +89,10 @@ LPSTR freerdp_get_dynamic_addin_install_path()
|
|||||||
return pszPath;
|
return pszPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* freerdp_load_dynamic_addin(LPCSTR pszFileName, LPCSTR pszPath, LPCSTR pszEntryName)
|
PVIRTUALCHANNELENTRY freerdp_load_dynamic_addin(LPCSTR pszFileName,
|
||||||
|
LPCSTR pszPath, LPCSTR pszEntryName)
|
||||||
{
|
{
|
||||||
void* entry;
|
PVIRTUALCHANNELENTRY entry;
|
||||||
BOOL bHasExt;
|
BOOL bHasExt;
|
||||||
PCSTR pszExt;
|
PCSTR pszExt;
|
||||||
size_t cchExt;
|
size_t cchExt;
|
||||||
@ -105,7 +104,6 @@ void* freerdp_load_dynamic_addin(LPCSTR pszFileName, LPCSTR pszPath, LPCSTR pszE
|
|||||||
size_t cchAddinFile;
|
size_t cchAddinFile;
|
||||||
LPSTR pszAddinInstallPath;
|
LPSTR pszAddinInstallPath;
|
||||||
size_t cchAddinInstallPath;
|
size_t cchAddinInstallPath;
|
||||||
|
|
||||||
entry = NULL;
|
entry = NULL;
|
||||||
cchExt = 0;
|
cchExt = 0;
|
||||||
bHasExt = TRUE;
|
bHasExt = TRUE;
|
||||||
@ -119,12 +117,14 @@ void* freerdp_load_dynamic_addin(LPCSTR pszFileName, LPCSTR pszPath, LPCSTR pszE
|
|||||||
}
|
}
|
||||||
|
|
||||||
pszAddinInstallPath = freerdp_get_dynamic_addin_install_path();
|
pszAddinInstallPath = freerdp_get_dynamic_addin_install_path();
|
||||||
|
|
||||||
if (!pszAddinInstallPath)
|
if (!pszAddinInstallPath)
|
||||||
return NULL;
|
return NULL;
|
||||||
cchAddinInstallPath = strlen(pszAddinInstallPath);
|
|
||||||
|
|
||||||
|
cchAddinInstallPath = strlen(pszAddinInstallPath);
|
||||||
cchFilePath = cchAddinInstallPath + cchFileName + 32;
|
cchFilePath = cchAddinInstallPath + cchFileName + 32;
|
||||||
pszFilePath = (LPSTR) malloc(cchFilePath + 1);
|
pszFilePath = (LPSTR) malloc(cchFilePath + 1);
|
||||||
|
|
||||||
if (!pszFilePath)
|
if (!pszFilePath)
|
||||||
{
|
{
|
||||||
free(pszAddinInstallPath);
|
free(pszAddinInstallPath);
|
||||||
@ -134,35 +134,37 @@ void* freerdp_load_dynamic_addin(LPCSTR pszFileName, LPCSTR pszPath, LPCSTR pszE
|
|||||||
if (bHasExt)
|
if (bHasExt)
|
||||||
{
|
{
|
||||||
pszAddinFile = _strdup(pszFileName);
|
pszAddinFile = _strdup(pszFileName);
|
||||||
|
|
||||||
if (!pszAddinFile)
|
if (!pszAddinFile)
|
||||||
{
|
{
|
||||||
free(pszAddinInstallPath);
|
free(pszAddinInstallPath);
|
||||||
free(pszFilePath);
|
free(pszFilePath);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
cchAddinFile = strlen(pszAddinFile);
|
cchAddinFile = strlen(pszAddinFile);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cchAddinFile = cchFileName + cchExt + 2 + sizeof(FREERDP_SHARED_LIBRARY_PREFIX);
|
cchAddinFile = cchFileName + cchExt + 2 + sizeof(FREERDP_SHARED_LIBRARY_PREFIX);
|
||||||
pszAddinFile = (LPSTR) malloc(cchAddinFile + 1);
|
pszAddinFile = (LPSTR) malloc(cchAddinFile + 1);
|
||||||
|
|
||||||
if (!pszAddinFile)
|
if (!pszAddinFile)
|
||||||
{
|
{
|
||||||
free(pszAddinInstallPath);
|
free(pszAddinInstallPath);
|
||||||
free(pszFilePath);
|
free(pszFilePath);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
sprintf_s(pszAddinFile, cchAddinFile, FREERDP_SHARED_LIBRARY_PREFIX"%s%s", pszFileName, pszExt);
|
|
||||||
|
sprintf_s(pszAddinFile, cchAddinFile, FREERDP_SHARED_LIBRARY_PREFIX"%s%s",
|
||||||
|
pszFileName, pszExt);
|
||||||
cchAddinFile = strlen(pszAddinFile);
|
cchAddinFile = strlen(pszAddinFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
CopyMemory(pszFilePath, pszAddinInstallPath, cchAddinInstallPath);
|
CopyMemory(pszFilePath, pszAddinInstallPath, cchAddinInstallPath);
|
||||||
pszFilePath[cchAddinInstallPath] = '\0';
|
pszFilePath[cchAddinInstallPath] = '\0';
|
||||||
|
|
||||||
NativePathCchAppendA((LPSTR) pszFilePath, cchFilePath + 1, pszAddinFile);
|
NativePathCchAppendA((LPSTR) pszFilePath, cchFilePath + 1, pszAddinFile);
|
||||||
|
|
||||||
library = LoadLibraryA(pszFilePath);
|
library = LoadLibraryA(pszFilePath);
|
||||||
|
|
||||||
free(pszAddinInstallPath);
|
free(pszAddinInstallPath);
|
||||||
free(pszAddinFile);
|
free(pszAddinFile);
|
||||||
free(pszFilePath);
|
free(pszFilePath);
|
||||||
@ -170,7 +172,7 @@ void* freerdp_load_dynamic_addin(LPCSTR pszFileName, LPCSTR pszPath, LPCSTR pszE
|
|||||||
if (!library)
|
if (!library)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
entry = GetProcAddress(library, pszEntryName);
|
entry = (PVIRTUALCHANNELENTRY)GetProcAddress(library, pszEntryName);
|
||||||
|
|
||||||
if (entry)
|
if (entry)
|
||||||
return entry;
|
return entry;
|
||||||
@ -179,43 +181,51 @@ void* freerdp_load_dynamic_addin(LPCSTR pszFileName, LPCSTR pszPath, LPCSTR pszE
|
|||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* freerdp_load_dynamic_channel_addin_entry(LPCSTR pszName, LPSTR pszSubsystem, LPSTR pszType, DWORD dwFlags)
|
PVIRTUALCHANNELENTRY freerdp_load_dynamic_channel_addin_entry(LPCSTR pszName,
|
||||||
|
LPSTR pszSubsystem, LPSTR pszType, DWORD dwFlags)
|
||||||
{
|
{
|
||||||
void* entry;
|
PVIRTUALCHANNELENTRY entry;
|
||||||
LPSTR pszFileName;
|
LPSTR pszFileName;
|
||||||
size_t cchFileName = sizeof(FREERDP_SHARED_LIBRARY_PREFIX) + 32;
|
size_t cchFileName = sizeof(FREERDP_SHARED_LIBRARY_PREFIX) + 32;
|
||||||
LPCSTR pszExtension;
|
LPCSTR pszExtension;
|
||||||
LPCSTR pszPrefix = FREERDP_SHARED_LIBRARY_PREFIX;
|
LPCSTR pszPrefix = FREERDP_SHARED_LIBRARY_PREFIX;
|
||||||
|
|
||||||
pszExtension = PathGetSharedLibraryExtensionA(0);
|
pszExtension = PathGetSharedLibraryExtensionA(0);
|
||||||
|
|
||||||
if (pszName && pszSubsystem && pszType)
|
if (pszName && pszSubsystem && pszType)
|
||||||
{
|
{
|
||||||
cchFileName += strlen(pszName) + strlen(pszSubsystem) + strlen(pszType) + strlen(pszExtension);
|
cchFileName += strlen(pszName) + strlen(pszSubsystem) + strlen(
|
||||||
|
pszType) + strlen(pszExtension);
|
||||||
pszFileName = (LPSTR) malloc(cchFileName);
|
pszFileName = (LPSTR) malloc(cchFileName);
|
||||||
|
|
||||||
if (!pszFileName)
|
if (!pszFileName)
|
||||||
return NULL;
|
return NULL;
|
||||||
sprintf_s(pszFileName, cchFileName, "%s%s-client-%s-%s.%s", pszPrefix, pszName, pszSubsystem, pszType, pszExtension);
|
|
||||||
|
sprintf_s(pszFileName, cchFileName, "%s%s-client-%s-%s.%s", pszPrefix, pszName,
|
||||||
|
pszSubsystem, pszType, pszExtension);
|
||||||
cchFileName = strlen(pszFileName);
|
cchFileName = strlen(pszFileName);
|
||||||
}
|
}
|
||||||
else if (pszName && pszSubsystem)
|
else if (pszName && pszSubsystem)
|
||||||
{
|
{
|
||||||
cchFileName += strlen(pszName) + strlen(pszSubsystem) + strlen(pszExtension);
|
cchFileName += strlen(pszName) + strlen(pszSubsystem) + strlen(pszExtension);
|
||||||
pszFileName = (LPSTR) malloc(cchFileName);
|
pszFileName = (LPSTR) malloc(cchFileName);
|
||||||
|
|
||||||
if (!pszFileName)
|
if (!pszFileName)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
sprintf_s(pszFileName, cchFileName, "%s%s-client-%s.%s", pszPrefix, pszName, pszSubsystem, pszExtension);
|
sprintf_s(pszFileName, cchFileName, "%s%s-client-%s.%s", pszPrefix, pszName,
|
||||||
|
pszSubsystem, pszExtension);
|
||||||
cchFileName = strlen(pszFileName);
|
cchFileName = strlen(pszFileName);
|
||||||
}
|
}
|
||||||
else if (pszName)
|
else if (pszName)
|
||||||
{
|
{
|
||||||
cchFileName += strlen(pszName) + strlen(pszExtension);
|
cchFileName += strlen(pszName) + strlen(pszExtension);
|
||||||
pszFileName = (LPSTR) malloc(cchFileName);
|
pszFileName = (LPSTR) malloc(cchFileName);
|
||||||
|
|
||||||
if (!pszFileName)
|
if (!pszFileName)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
sprintf_s(pszFileName, cchFileName, "%s%s-client.%s", pszPrefix, pszName, pszExtension);
|
sprintf_s(pszFileName, cchFileName, "%s%s-client.%s", pszPrefix, pszName,
|
||||||
|
pszExtension);
|
||||||
cchFileName = strlen(pszFileName);
|
cchFileName = strlen(pszFileName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -227,23 +237,21 @@ void* freerdp_load_dynamic_channel_addin_entry(LPCSTR pszName, LPSTR pszSubsyste
|
|||||||
{
|
{
|
||||||
LPSTR pszEntryName;
|
LPSTR pszEntryName;
|
||||||
size_t cchEntryName;
|
size_t cchEntryName;
|
||||||
|
|
||||||
/* subsystem add-in */
|
/* subsystem add-in */
|
||||||
|
|
||||||
cchEntryName = 64 + strlen(pszName);
|
cchEntryName = 64 + strlen(pszName);
|
||||||
pszEntryName = (LPSTR) malloc(cchEntryName + 1);
|
pszEntryName = (LPSTR) malloc(cchEntryName + 1);
|
||||||
|
|
||||||
if (!pszEntryName)
|
if (!pszEntryName)
|
||||||
{
|
{
|
||||||
free(pszFileName);
|
free(pszFileName);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
sprintf_s(pszEntryName, cchEntryName + 1, "freerdp_%s_client_subsystem_entry", pszName);
|
|
||||||
|
|
||||||
|
sprintf_s(pszEntryName, cchEntryName + 1, "freerdp_%s_client_subsystem_entry",
|
||||||
|
pszName);
|
||||||
entry = freerdp_load_dynamic_addin(pszFileName, NULL, pszEntryName);
|
entry = freerdp_load_dynamic_addin(pszFileName, NULL, pszEntryName);
|
||||||
|
|
||||||
free(pszEntryName);
|
free(pszEntryName);
|
||||||
free(pszFileName);
|
free(pszFileName);
|
||||||
|
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,23 +270,28 @@ void* freerdp_load_dynamic_channel_addin_entry(LPCSTR pszName, LPSTR pszSubsyste
|
|||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FREERDP_LOAD_CHANNEL_ADDIN_ENTRY_FN freerdp_load_static_channel_addin_entry = NULL;
|
static FREERDP_LOAD_CHANNEL_ADDIN_ENTRY_FN
|
||||||
|
freerdp_load_static_channel_addin_entry = NULL;
|
||||||
|
|
||||||
int freerdp_register_addin_provider(FREERDP_LOAD_CHANNEL_ADDIN_ENTRY_FN provider, DWORD dwFlags)
|
int freerdp_register_addin_provider(FREERDP_LOAD_CHANNEL_ADDIN_ENTRY_FN
|
||||||
|
provider, DWORD dwFlags)
|
||||||
{
|
{
|
||||||
freerdp_load_static_channel_addin_entry = provider;
|
freerdp_load_static_channel_addin_entry = provider;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* freerdp_load_channel_addin_entry(LPCSTR pszName, LPSTR pszSubsystem, LPSTR pszType, DWORD dwFlags)
|
PVIRTUALCHANNELENTRY freerdp_load_channel_addin_entry(LPCSTR pszName,
|
||||||
|
LPSTR pszSubsystem, LPSTR pszType, DWORD dwFlags)
|
||||||
{
|
{
|
||||||
void* entry = NULL;
|
PVIRTUALCHANNELENTRY entry = NULL;
|
||||||
|
|
||||||
if (freerdp_load_static_channel_addin_entry)
|
if (freerdp_load_static_channel_addin_entry)
|
||||||
entry = freerdp_load_static_channel_addin_entry(pszName, pszSubsystem, pszType, dwFlags);
|
entry = freerdp_load_static_channel_addin_entry(pszName, pszSubsystem, pszType,
|
||||||
|
dwFlags);
|
||||||
|
|
||||||
if (!entry)
|
if (!entry)
|
||||||
entry = freerdp_load_dynamic_channel_addin_entry(pszName, pszSubsystem, pszType, dwFlags);
|
entry = freerdp_load_dynamic_channel_addin_entry(pszName, pszSubsystem, pszType,
|
||||||
|
dwFlags);
|
||||||
|
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
@ -770,8 +770,8 @@ int freerdp_channels_client_load(rdpChannels* channels, rdpSettings* settings,
|
|||||||
int freerdp_channels_load_plugin(rdpChannels* channels, rdpSettings* settings,
|
int freerdp_channels_load_plugin(rdpChannels* channels, rdpSettings* settings,
|
||||||
const char* name, void* data)
|
const char* name, void* data)
|
||||||
{
|
{
|
||||||
void* entry;
|
PVIRTUALCHANNELENTRY entry;
|
||||||
entry = (PVIRTUALCHANNELENTRY) freerdp_load_channel_addin_entry(name, NULL,
|
entry = freerdp_load_channel_addin_entry(name, NULL,
|
||||||
NULL, FREERDP_ADDIN_CHANNEL_STATIC);
|
NULL, FREERDP_ADDIN_CHANNEL_STATIC);
|
||||||
|
|
||||||
if (!entry)
|
if (!entry)
|
||||||
|
Loading…
Reference in New Issue
Block a user