Fixed addin tables and casts.

This commit is contained in:
Armin Novak 2017-04-10 10:38:38 +02:00
parent 9fd3974817
commit 9713b63c26
4 changed files with 19 additions and 16 deletions

View File

@ -28,23 +28,26 @@ if(CHANNEL_STATIC_CLIENT_ENTRIES)
list(REMOVE_DUPLICATES CHANNEL_STATIC_CLIENT_ENTRIES)
endif()
set(CLIENT_STATIC_TYPEDEFS "typedef UINT (*static_entry_fkt)();\n")
set(CLIENT_STATIC_TYPEDEFS "${CLIENT_STATIC_TYPEDEFS}typedef UINT (*static_addin_fkt)();\n")
foreach(STATIC_ENTRY ${CHANNEL_STATIC_CLIENT_ENTRIES})
foreach(STATIC_MODULE ${CHANNEL_STATIC_CLIENT_MODULES})
if(${${STATIC_MODULE}_CLIENT_ENTRY} STREQUAL ${STATIC_ENTRY})
set(STATIC_MODULE_NAME ${${STATIC_MODULE}_CLIENT_NAME})
set(STATIC_MODULE_CHANNEL ${${STATIC_MODULE}_CLIENT_CHANNEL})
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${STATIC_MODULE_NAME})
set(ENTRY_POINT_NAME "${STATIC_MODULE_CHANNEL}_${${STATIC_MODULE}_CLIENT_ENTRY}")
if(${${STATIC_MODULE}_CLIENT_ENTRY} STREQUAL "VirtualChannelEntry")
set(ENTRY_POINT_IMPORT "extern BOOL VCAPITYPE ${ENTRY_POINT_NAME}(PCHANNEL_ENTRY_POINTS);")
elseif(${${STATIC_MODULE}_CLIENT_ENTRY} STREQUAL "VirtualChannelEntryEx")
set(ENTRY_POINT_IMPORT "extern BOOL VCAPITYPE ${ENTRY_POINT_NAME}(PCHANNEL_ENTRY_POINTS,PVOID);")
else()
set(ENTRY_POINT_IMPORT "extern UINT ${ENTRY_POINT_NAME}();")
set(ENTRY_POINT_IMPORT "extern UINT ${ENTRY_POINT_NAME}(void);")
endif()
set(${STATIC_ENTRY}_IMPORTS "${${STATIC_ENTRY}_IMPORTS}\n${ENTRY_POINT_IMPORT}")
set(${STATIC_ENTRY}_TABLE "${${STATIC_ENTRY}_TABLE}\n\t{ \"${STATIC_MODULE_CHANNEL}\", ${ENTRY_POINT_NAME} },")
set(${STATIC_ENTRY}_TABLE "${${STATIC_ENTRY}_TABLE}\n\t{ \"${STATIC_MODULE_CHANNEL}\", (static_entry_fkt)${ENTRY_POINT_NAME} },")
endif()
endforeach()
endforeach()
@ -88,13 +91,13 @@ foreach(STATIC_MODULE ${CHANNEL_STATIC_CLIENT_MODULES})
set(STATIC_SUBSYSTEM_ENTRY "${STATIC_SUBSYSTEM_NAME}_freerdp_${STATIC_MODULE_CHANNEL}_client_subsystem_entry")
endif()
set(SUBSYSTEM_TABLE "${SUBSYSTEM_TABLE}\n\t{ \"${STATIC_SUBSYSTEM_NAME}\", \"${STATIC_SUBSYSTEM_TYPE}\", ${STATIC_SUBSYSTEM_ENTRY} },")
set(SUBSYSTEM_IMPORT "extern void ${STATIC_SUBSYSTEM_ENTRY}();")
set(SUBSYSTEM_IMPORT "extern void ${STATIC_SUBSYSTEM_ENTRY}(void);")
set(CLIENT_STATIC_SUBSYSTEM_IMPORTS "${CLIENT_STATIC_SUBSYSTEM_IMPORTS}\n${SUBSYSTEM_IMPORT}")
endforeach()
set(SUBSYSTEM_TABLE "${SUBSYSTEM_TABLE}\n\t{ NULL, NULL, NULL }\n};")
set(CLIENT_STATIC_SUBSYSTEM_TABLES "${CLIENT_STATIC_SUBSYSTEM_TABLES}\n${SUBSYSTEM_TABLE}")
set(ENTRY_POINT_NAME "${STATIC_MODULE_CHANNEL}_${${STATIC_MODULE}_CLIENT_ENTRY}")
set(CLIENT_STATIC_ADDIN_TABLE "${CLIENT_STATIC_ADDIN_TABLE}\n\t{ \"${STATIC_MODULE_CHANNEL}\", ${ENTRY_POINT_NAME}, ${SUBSYSTEM_TABLE_NAME} },")
set(CLIENT_STATIC_ADDIN_TABLE "${CLIENT_STATIC_ADDIN_TABLE}\n\t{ \"${STATIC_MODULE_CHANNEL}\", (static_addin_fkt)${ENTRY_POINT_NAME}, ${SUBSYSTEM_TABLE_NAME} },")
endforeach()
set(CLIENT_STATIC_ADDIN_TABLE "${CLIENT_STATIC_ADDIN_TABLE}\n\t{ NULL, NULL, NULL }\n};")

View File

@ -21,15 +21,11 @@
#include "tables.h"
${CLIENT_STATIC_TYPEDEFS}
${CLIENT_STATIC_ENTRY_IMPORTS}
${CLIENT_STATIC_ENTRY_TABLES}
${CLIENT_STATIC_ENTRY_TABLES_LIST}
${CLIENT_STATIC_SUBSYSTEM_IMPORTS}
${CLIENT_STATIC_SUBSYSTEM_TABLES}
${CLIENT_STATIC_ADDIN_TABLE}

View File

@ -22,7 +22,7 @@
struct _STATIC_ENTRY
{
const char* name;
const void* entry;
UINT(*entry)();
};
typedef struct _STATIC_ENTRY STATIC_ENTRY;
@ -37,14 +37,14 @@ struct _STATIC_SUBSYSTEM_ENTRY
{
const char* name;
const char* type;
const void* entry;
void (*entry)(void);
};
typedef struct _STATIC_SUBSYSTEM_ENTRY STATIC_SUBSYSTEM_ENTRY;
struct _STATIC_ADDIN_TABLE
{
const char* name;
const void* entry;
UINT(*entry)();
const STATIC_SUBSYSTEM_ENTRY* table;
};
typedef struct _STATIC_ADDIN_TABLE STATIC_ADDIN_TABLE;

View File

@ -39,8 +39,10 @@ static INLINE BOOL is_path_required(LPCSTR path, size_t len)
{
if (!path || (len <= 1))
return FALSE;
if (strcmp(path, ".") == 0)
return FALSE;
return TRUE;
}
@ -56,7 +58,6 @@ LPSTR freerdp_get_library_install_path(void)
cchLibraryPath = strlen(pszLibraryPath) + 1;
cchInstallPrefix = strlen(pszInstallPrefix) + 1;
cchPath = cchInstallPrefix + cchLibraryPath;
needInstallPath = is_path_required(pszInstallPrefix, cchInstallPrefix);
needLibPath = is_path_required(pszLibraryPath, cchLibraryPath);
@ -98,7 +99,6 @@ LPSTR freerdp_get_dynamic_addin_install_path(void)
cchAddinPath = strlen(pszAddinPath) + 1;
cchInstallPrefix = strlen(pszInstallPrefix) + 1;
cchPath = cchInstallPrefix + cchAddinPath;
needInstallPath = is_path_required(pszInstallPrefix, cchInstallPrefix);
needLibPath = is_path_required(pszAddinPath, cchAddinPath);
@ -176,6 +176,7 @@ PVIRTUALCHANNELENTRY freerdp_load_dynamic_addin(LPCSTR pszFileName,
sprintf_s(pszAddinFile, cchAddinFile, FREERDP_SHARED_LIBRARY_PREFIX"%s%s",
pszFileName, pszExt);
}
cchAddinFile = strlen(pszAddinFile);
/* If a path is provided prefix the library name with it. */
@ -183,8 +184,10 @@ PVIRTUALCHANNELENTRY freerdp_load_dynamic_addin(LPCSTR pszFileName,
{
size_t relPathLen = strlen(pszPath) + cchAddinFile + 1;
pszRelativeFilePath = calloc(relPathLen, sizeof(CHAR));
if (!pszRelativeFilePath)
goto fail;
sprintf_s(pszRelativeFilePath, relPathLen, "%s", pszRelativeFilePath);
NativePathCchAppendA(pszRelativeFilePath, relPathLen, pszAddinFile);
}
@ -217,14 +220,15 @@ PVIRTUALCHANNELENTRY freerdp_load_dynamic_addin(LPCSTR pszFileName,
goto fail;
entry = (PVIRTUALCHANNELENTRY)GetProcAddress(library, pszEntryName);
fail:
free(pszRelativeFilePath);
free(pszAddinFile);
free(pszFilePath);
free(pszAddinInstallPath);
if (!entry && library)
FreeLibrary(library);
return entry;
}