[function pointers] unify casts with macro
This commit is contained in:
parent
1a9766e190
commit
245afb706c
@ -811,14 +811,10 @@ static UINT audin_load_device_plugin(AUDIN_PLUGIN* audin, const char* name, cons
|
|||||||
FREERDP_AUDIN_DEVICE_ENTRY_POINTS entryPoints = { 0 };
|
FREERDP_AUDIN_DEVICE_ENTRY_POINTS entryPoints = { 0 };
|
||||||
UINT error = ERROR_INTERNAL_ERROR;
|
UINT error = ERROR_INTERNAL_ERROR;
|
||||||
|
|
||||||
union
|
PVIRTUALCHANNELENTRY pvce = freerdp_load_channel_addin_entry(AUDIN_CHANNEL_NAME, name, NULL, 0);
|
||||||
{
|
PFREERDP_AUDIN_DEVICE_ENTRY entry = WINPR_FUNC_PTR_CAST(pvce, PFREERDP_AUDIN_DEVICE_ENTRY);
|
||||||
PVIRTUALCHANNELENTRY pvce;
|
|
||||||
PFREERDP_AUDIN_DEVICE_ENTRY entry;
|
|
||||||
} cnv;
|
|
||||||
cnv.pvce = freerdp_load_channel_addin_entry(AUDIN_CHANNEL_NAME, name, NULL, 0);
|
|
||||||
|
|
||||||
if (cnv.entry == NULL)
|
if (entry == NULL)
|
||||||
{
|
{
|
||||||
WLog_Print(audin->log, WLOG_ERROR,
|
WLog_Print(audin->log, WLOG_ERROR,
|
||||||
"freerdp_load_channel_addin_entry did not return any function pointers for %s ",
|
"freerdp_load_channel_addin_entry did not return any function pointers for %s ",
|
||||||
@ -831,7 +827,7 @@ static UINT audin_load_device_plugin(AUDIN_PLUGIN* audin, const char* name, cons
|
|||||||
entryPoints.args = args;
|
entryPoints.args = args;
|
||||||
entryPoints.rdpcontext = audin->rdpcontext;
|
entryPoints.rdpcontext = audin->rdpcontext;
|
||||||
|
|
||||||
error = cnv.entry(&entryPoints);
|
error = entry(&entryPoints);
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
WLog_Print(audin->log, WLOG_ERROR, "%s entry returned error %" PRIu32 ".", name, error);
|
WLog_Print(audin->log, WLOG_ERROR, "%s entry returned error %" PRIu32 ".", name, error);
|
||||||
|
@ -52,16 +52,9 @@ static void* freerdp_channels_find_static_entry_in_table(const STATIC_ENTRY_TABL
|
|||||||
|
|
||||||
while (pEntry->entry != NULL)
|
while (pEntry->entry != NULL)
|
||||||
{
|
{
|
||||||
|
static_entry_fn_t fkt = pEntry->entry;
|
||||||
if (strcmp(pEntry->name, identifier) == 0)
|
if (strcmp(pEntry->name, identifier) == 0)
|
||||||
{
|
return WINPR_FUNC_PTR_CAST(fkt, void*);
|
||||||
union
|
|
||||||
{
|
|
||||||
void* pv;
|
|
||||||
static_entry_fn_t entry;
|
|
||||||
} cnv;
|
|
||||||
cnv.entry = pEntry->entry;
|
|
||||||
return cnv.pv;
|
|
||||||
}
|
|
||||||
|
|
||||||
pEntry = &table->table.cse[index++];
|
pEntry = &table->table.cse[index++];
|
||||||
}
|
}
|
||||||
@ -494,20 +487,15 @@ PVIRTUALCHANNELENTRY freerdp_channels_load_static_addin_entry(LPCSTR pszName, LP
|
|||||||
0) || /* we only want to know if strnlen is > 0 */
|
0) || /* we only want to know if strnlen is > 0 */
|
||||||
(strncmp(subsystems->name, pszSubsystem, MAX_PATH) == 0))
|
(strncmp(subsystems->name, pszSubsystem, MAX_PATH) == 0))
|
||||||
{
|
{
|
||||||
/* cast with union trick to avoid -Wcast-function-type-strict */
|
static_subsystem_entry_fn_t fkt = subsystems->entry;
|
||||||
union
|
|
||||||
{
|
|
||||||
PVIRTUALCHANNELENTRY pvce;
|
|
||||||
static_subsystem_entry_fn_t entry;
|
|
||||||
} cnv;
|
|
||||||
cnv.entry = subsystems->entry;
|
|
||||||
if (pszType)
|
if (pszType)
|
||||||
{
|
{
|
||||||
if (strncmp(subsystems->type, pszType, MAX_PATH) == 0)
|
if (strncmp(subsystems->type, pszType, MAX_PATH) == 0)
|
||||||
return cnv.pvce;
|
return WINPR_FUNC_PTR_CAST(fkt, PVIRTUALCHANNELENTRY);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return cnv.pvce;
|
return WINPR_FUNC_PTR_CAST(fkt, PVIRTUALCHANNELENTRY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -359,15 +359,11 @@ static UINT dvcman_load_addin(drdynvcPlugin* drdynvc, IWTSVirtualChannelManager*
|
|||||||
|
|
||||||
WLog_Print(drdynvc->log, WLOG_INFO, "Loading Dynamic Virtual Channel %s", args->argv[0]);
|
WLog_Print(drdynvc->log, WLOG_INFO, "Loading Dynamic Virtual Channel %s", args->argv[0]);
|
||||||
|
|
||||||
union
|
PVIRTUALCHANNELENTRY pvce =
|
||||||
{
|
|
||||||
PVIRTUALCHANNELENTRY pvce;
|
|
||||||
PDVC_PLUGIN_ENTRY pDVCPluginEntry;
|
|
||||||
} cnv;
|
|
||||||
cnv.pvce =
|
|
||||||
freerdp_load_channel_addin_entry(args->argv[0], NULL, NULL, FREERDP_ADDIN_CHANNEL_DYNAMIC);
|
freerdp_load_channel_addin_entry(args->argv[0], NULL, NULL, FREERDP_ADDIN_CHANNEL_DYNAMIC);
|
||||||
|
PDVC_PLUGIN_ENTRY pDVCPluginEntry = WINPR_FUNC_PTR_CAST(pvce, PDVC_PLUGIN_ENTRY);
|
||||||
|
|
||||||
if (cnv.pDVCPluginEntry)
|
if (pDVCPluginEntry)
|
||||||
{
|
{
|
||||||
DVCMAN_ENTRY_POINTS entryPoints = { 0 };
|
DVCMAN_ENTRY_POINTS entryPoints = { 0 };
|
||||||
|
|
||||||
@ -379,7 +375,7 @@ static UINT dvcman_load_addin(drdynvcPlugin* drdynvc, IWTSVirtualChannelManager*
|
|||||||
entryPoints.dvcman = (DVCMAN*)pChannelMgr;
|
entryPoints.dvcman = (DVCMAN*)pChannelMgr;
|
||||||
entryPoints.args = args;
|
entryPoints.args = args;
|
||||||
entryPoints.context = context;
|
entryPoints.context = context;
|
||||||
return cnv.pDVCPluginEntry(&entryPoints.iface);
|
return pDVCPluginEntry(&entryPoints.iface);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ERROR_INVALID_FUNCTION;
|
return ERROR_INVALID_FUNCTION;
|
||||||
|
@ -1049,18 +1049,13 @@ error_out:
|
|||||||
static rdpPrinterDriver* printer_load_backend(const char* backend)
|
static rdpPrinterDriver* printer_load_backend(const char* backend)
|
||||||
{
|
{
|
||||||
typedef UINT (*backend_load_t)(rdpPrinterDriver**);
|
typedef UINT (*backend_load_t)(rdpPrinterDriver**);
|
||||||
union
|
PVIRTUALCHANNELENTRY entry = freerdp_load_channel_addin_entry("printer", backend, NULL, 0);
|
||||||
{
|
backend_load_t func = WINPR_FUNC_PTR_CAST(entry, backend_load_t);
|
||||||
PVIRTUALCHANNELENTRY entry;
|
if (!func)
|
||||||
backend_load_t backend;
|
|
||||||
} fktconv;
|
|
||||||
|
|
||||||
fktconv.entry = freerdp_load_channel_addin_entry("printer", backend, NULL, 0);
|
|
||||||
if (!fktconv.entry)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
rdpPrinterDriver* printer = NULL;
|
rdpPrinterDriver* printer = NULL;
|
||||||
const UINT rc = fktconv.backend(&printer);
|
const UINT rc = func(&printer);
|
||||||
if (rc != CHANNEL_RC_OK)
|
if (rc != CHANNEL_RC_OK)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -187,11 +187,6 @@ UINT devman_load_device_service(DEVMAN* devman, const RDPDR_DEVICE* device, rdpC
|
|||||||
const char* ServiceName = NULL;
|
const char* ServiceName = NULL;
|
||||||
DEVICE_SERVICE_ENTRY_POINTS ep = { 0 };
|
DEVICE_SERVICE_ENTRY_POINTS ep = { 0 };
|
||||||
union
|
union
|
||||||
{
|
|
||||||
PVIRTUALCHANNELENTRY pvce;
|
|
||||||
PDEVICE_SERVICE_ENTRY entry;
|
|
||||||
} cnv;
|
|
||||||
union
|
|
||||||
{
|
{
|
||||||
const RDPDR_DEVICE* cdp;
|
const RDPDR_DEVICE* cdp;
|
||||||
RDPDR_DEVICE* dp;
|
RDPDR_DEVICE* dp;
|
||||||
@ -223,9 +218,11 @@ UINT devman_load_device_service(DEVMAN* devman, const RDPDR_DEVICE* device, rdpC
|
|||||||
else
|
else
|
||||||
WLog_INFO(TAG, "Loading device service %s (static)", ServiceName);
|
WLog_INFO(TAG, "Loading device service %s (static)", ServiceName);
|
||||||
|
|
||||||
cnv.pvce = freerdp_load_channel_addin_entry(ServiceName, NULL, "DeviceServiceEntry", 0);
|
PVIRTUALCHANNELENTRY pvce =
|
||||||
|
freerdp_load_channel_addin_entry(ServiceName, NULL, "DeviceServiceEntry", 0);
|
||||||
|
PDEVICE_SERVICE_ENTRY entry = WINPR_FUNC_PTR_CAST(pvce, PDEVICE_SERVICE_ENTRY);
|
||||||
|
|
||||||
if (!cnv.entry)
|
if (!entry)
|
||||||
{
|
{
|
||||||
WLog_INFO(TAG, "freerdp_load_channel_addin_entry failed!");
|
WLog_INFO(TAG, "freerdp_load_channel_addin_entry failed!");
|
||||||
return ERROR_INTERNAL_ERROR;
|
return ERROR_INTERNAL_ERROR;
|
||||||
@ -235,5 +232,5 @@ UINT devman_load_device_service(DEVMAN* devman, const RDPDR_DEVICE* device, rdpC
|
|||||||
ep.RegisterDevice = devman_register_device;
|
ep.RegisterDevice = devman_register_device;
|
||||||
ep.device = devconv.dp;
|
ep.device = devconv.dp;
|
||||||
ep.rdpcontext = rdpcontext;
|
ep.rdpcontext = rdpcontext;
|
||||||
return cnv.entry(&ep);
|
return entry(&ep);
|
||||||
}
|
}
|
||||||
|
@ -848,27 +848,23 @@ static void rdpsnd_register_device_plugin(rdpsndPlugin* rdpsnd, rdpsndDevicePlug
|
|||||||
static UINT rdpsnd_load_device_plugin(rdpsndPlugin* rdpsnd, const char* name,
|
static UINT rdpsnd_load_device_plugin(rdpsndPlugin* rdpsnd, const char* name,
|
||||||
const ADDIN_ARGV* args)
|
const ADDIN_ARGV* args)
|
||||||
{
|
{
|
||||||
union
|
|
||||||
{
|
|
||||||
PVIRTUALCHANNELENTRY pvce;
|
|
||||||
PFREERDP_RDPSND_DEVICE_ENTRY entry;
|
|
||||||
} cnv;
|
|
||||||
|
|
||||||
FREERDP_RDPSND_DEVICE_ENTRY_POINTS entryPoints = { 0 };
|
FREERDP_RDPSND_DEVICE_ENTRY_POINTS entryPoints = { 0 };
|
||||||
UINT error = 0;
|
UINT error = 0;
|
||||||
DWORD flags = FREERDP_ADDIN_CHANNEL_STATIC | FREERDP_ADDIN_CHANNEL_ENTRYEX;
|
DWORD flags = FREERDP_ADDIN_CHANNEL_STATIC | FREERDP_ADDIN_CHANNEL_ENTRYEX;
|
||||||
if (rdpsnd->dynamic)
|
if (rdpsnd->dynamic)
|
||||||
flags = FREERDP_ADDIN_CHANNEL_DYNAMIC;
|
flags = FREERDP_ADDIN_CHANNEL_DYNAMIC;
|
||||||
cnv.pvce = freerdp_load_channel_addin_entry(RDPSND_CHANNEL_NAME, name, NULL, flags);
|
PVIRTUALCHANNELENTRY pvce =
|
||||||
|
freerdp_load_channel_addin_entry(RDPSND_CHANNEL_NAME, name, NULL, flags);
|
||||||
|
PFREERDP_RDPSND_DEVICE_ENTRY entry = WINPR_FUNC_PTR_CAST(pvce, PFREERDP_RDPSND_DEVICE_ENTRY);
|
||||||
|
|
||||||
if (!cnv.entry)
|
if (!entry)
|
||||||
return ERROR_INTERNAL_ERROR;
|
return ERROR_INTERNAL_ERROR;
|
||||||
|
|
||||||
entryPoints.rdpsnd = rdpsnd;
|
entryPoints.rdpsnd = rdpsnd;
|
||||||
entryPoints.pRegisterRdpsndDevice = rdpsnd_register_device_plugin;
|
entryPoints.pRegisterRdpsndDevice = rdpsnd_register_device_plugin;
|
||||||
entryPoints.args = args;
|
entryPoints.args = args;
|
||||||
|
|
||||||
error = cnv.entry(&entryPoints);
|
error = entry(&entryPoints);
|
||||||
if (error)
|
if (error)
|
||||||
WLog_ERR(TAG, "%s %s entry returns error %" PRIu32 "", rdpsnd_is_dyn_str(rdpsnd->dynamic),
|
WLog_ERR(TAG, "%s %s entry returns error %" PRIu32 "", rdpsnd_is_dyn_str(rdpsnd->dynamic),
|
||||||
name, error);
|
name, error);
|
||||||
|
@ -770,21 +770,19 @@ static UINT urbdrc_load_udevman_addin(IWTSPlugin* pPlugin, LPCSTR name, const AD
|
|||||||
{
|
{
|
||||||
URBDRC_PLUGIN* urbdrc = (URBDRC_PLUGIN*)pPlugin;
|
URBDRC_PLUGIN* urbdrc = (URBDRC_PLUGIN*)pPlugin;
|
||||||
FREERDP_URBDRC_SERVICE_ENTRY_POINTS entryPoints = { 0 };
|
FREERDP_URBDRC_SERVICE_ENTRY_POINTS entryPoints = { 0 };
|
||||||
union
|
|
||||||
{
|
|
||||||
PVIRTUALCHANNELENTRY pvce;
|
|
||||||
PFREERDP_URBDRC_DEVICE_ENTRY entry;
|
|
||||||
} cnv;
|
|
||||||
cnv.pvce = freerdp_load_channel_addin_entry(URBDRC_CHANNEL_NAME, name, NULL, 0);
|
|
||||||
|
|
||||||
if (!cnv.entry)
|
PVIRTUALCHANNELENTRY pvce =
|
||||||
|
freerdp_load_channel_addin_entry(URBDRC_CHANNEL_NAME, name, NULL, 0);
|
||||||
|
PFREERDP_URBDRC_DEVICE_ENTRY entry = WINPR_FUNC_PTR_CAST(pvce, PFREERDP_URBDRC_DEVICE_ENTRY);
|
||||||
|
|
||||||
|
if (!entry)
|
||||||
return ERROR_INVALID_OPERATION;
|
return ERROR_INVALID_OPERATION;
|
||||||
|
|
||||||
entryPoints.plugin = pPlugin;
|
entryPoints.plugin = pPlugin;
|
||||||
entryPoints.pRegisterUDEVMAN = urbdrc_register_udevman_addin;
|
entryPoints.pRegisterUDEVMAN = urbdrc_register_udevman_addin;
|
||||||
entryPoints.args = args;
|
entryPoints.args = args;
|
||||||
|
|
||||||
const UINT error = cnv.entry(&entryPoints);
|
const UINT error = entry(&entryPoints);
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
WLog_Print(urbdrc->log, WLOG_ERROR, "%s entry returns error.", name);
|
WLog_Print(urbdrc->log, WLOG_ERROR, "%s entry returns error.", name);
|
||||||
|
@ -5716,22 +5716,17 @@ fail:
|
|||||||
static BOOL freerdp_client_load_static_channel_addin(rdpChannels* channels, rdpSettings* settings,
|
static BOOL freerdp_client_load_static_channel_addin(rdpChannels* channels, rdpSettings* settings,
|
||||||
const char* name, void* data)
|
const char* name, void* data)
|
||||||
{
|
{
|
||||||
union
|
|
||||||
{
|
|
||||||
PVIRTUALCHANNELENTRY pvce;
|
|
||||||
PVIRTUALCHANNELENTRYEX pvceex;
|
|
||||||
} cnv;
|
|
||||||
PVIRTUALCHANNELENTRY entry = NULL;
|
PVIRTUALCHANNELENTRY entry = NULL;
|
||||||
|
PVIRTUALCHANNELENTRY pvce = freerdp_load_channel_addin_entry(
|
||||||
cnv.pvce = freerdp_load_channel_addin_entry(
|
|
||||||
name, NULL, NULL, FREERDP_ADDIN_CHANNEL_STATIC | FREERDP_ADDIN_CHANNEL_ENTRYEX);
|
name, NULL, NULL, FREERDP_ADDIN_CHANNEL_STATIC | FREERDP_ADDIN_CHANNEL_ENTRYEX);
|
||||||
|
PVIRTUALCHANNELENTRYEX pvceex = WINPR_FUNC_PTR_CAST(pvce, PVIRTUALCHANNELENTRYEX);
|
||||||
|
|
||||||
if (!cnv.pvceex)
|
if (!pvceex)
|
||||||
entry = freerdp_load_channel_addin_entry(name, NULL, NULL, FREERDP_ADDIN_CHANNEL_STATIC);
|
entry = freerdp_load_channel_addin_entry(name, NULL, NULL, FREERDP_ADDIN_CHANNEL_STATIC);
|
||||||
|
|
||||||
if (cnv.pvceex)
|
if (pvceex)
|
||||||
{
|
{
|
||||||
if (freerdp_channels_client_load_ex(channels, settings, cnv.pvceex, data) == 0)
|
if (freerdp_channels_client_load_ex(channels, settings, pvceex, data) == 0)
|
||||||
{
|
{
|
||||||
WLog_DBG(TAG, "loading channelEx %s", name);
|
WLog_DBG(TAG, "loading channelEx %s", name);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -237,13 +237,8 @@ PVIRTUALCHANNELENTRY freerdp_load_dynamic_addin(LPCSTR pszFileName, LPCSTR pszPa
|
|||||||
if (!library)
|
if (!library)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
union
|
FARPROC fp = GetProcAddress(library, pszEntryName);
|
||||||
{
|
entry = WINPR_FUNC_PTR_CAST(fp, PVIRTUALCHANNELENTRY);
|
||||||
FARPROC fp;
|
|
||||||
PVIRTUALCHANNELENTRY entry;
|
|
||||||
} cnv;
|
|
||||||
cnv.fp = GetProcAddress(library, pszEntryName);
|
|
||||||
entry = cnv.entry;
|
|
||||||
fail:
|
fail:
|
||||||
free(pszRelativeFilePath);
|
free(pszRelativeFilePath);
|
||||||
free(pszAddinFile);
|
free(pszAddinFile);
|
||||||
|
@ -470,19 +470,16 @@ static BOOL createChildSessionTransport(HANDLE* pFile)
|
|||||||
WCHAR pipePath[0x80] = { 0 };
|
WCHAR pipePath[0x80] = { 0 };
|
||||||
char pipePathA[0x80] = { 0 };
|
char pipePathA[0x80] = { 0 };
|
||||||
|
|
||||||
union
|
FARPROC fp = GetProcAddress(hModule, "WinStationCreateChildSessionTransport");
|
||||||
{
|
WinStationCreateChildSessionTransportFn createChildSessionFn =
|
||||||
FARPROC fp;
|
WINPR_FUNC_PTR_CAST(fp, WinStationCreateChildSessionTransportFn);
|
||||||
WinStationCreateChildSessionTransportFn createChildSessionFn;
|
if (!createChildSessionFn)
|
||||||
} cnv;
|
|
||||||
cnv.fp = GetProcAddress(hModule, "WinStationCreateChildSessionTransport");
|
|
||||||
if (!cnv.createChildSessionFn)
|
|
||||||
{
|
{
|
||||||
WLog_ERR(TAG, "unable to retrieve WinStationCreateChildSessionTransport function");
|
WLog_ERR(TAG, "unable to retrieve WinStationCreateChildSessionTransport function");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT hStatus = cnv.createChildSessionFn(pipePath, 0x80);
|
HRESULT hStatus = createChildSessionFn(pipePath, 0x80);
|
||||||
if (!SUCCEEDED(hStatus))
|
if (!SUCCEEDED(hStatus))
|
||||||
{
|
{
|
||||||
WLog_ERR(TAG, "error 0x%x when creating childSessionTransport", hStatus);
|
WLog_ERR(TAG, "error 0x%x when creating childSessionTransport", hStatus);
|
||||||
|
@ -814,20 +814,17 @@ static SecurityFunctionTable* auth_resolve_sspi_table(const rdpSettings* setting
|
|||||||
|
|
||||||
WLog_INFO(TAG, "Using SSPI Module: %s", module_name);
|
WLog_INFO(TAG, "Using SSPI Module: %s", module_name);
|
||||||
|
|
||||||
union
|
FARPROC fp = GetProcAddress(hSSPI, proc_name);
|
||||||
{
|
INIT_SECURITY_INTERFACE InitSecurityInterface_ptr =
|
||||||
FARPROC fp;
|
WINPR_FUNC_PTR_CAST(fp, INIT_SECURITY_INTERFACE);
|
||||||
INIT_SECURITY_INTERFACE InitSecurityInterface_ptr;
|
if (!InitSecurityInterface_ptr)
|
||||||
} cnv;
|
|
||||||
cnv.fp = GetProcAddress(hSSPI, proc_name);
|
|
||||||
if (!cnv.InitSecurityInterface_ptr)
|
|
||||||
{
|
{
|
||||||
WLog_ERR(TAG, "Failed to load SSPI module: %s, no function %s", module_name, proc_name);
|
WLog_ERR(TAG, "Failed to load SSPI module: %s, no function %s", module_name, proc_name);
|
||||||
free(sspi_module);
|
free(sspi_module);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
free(sspi_module);
|
free(sspi_module);
|
||||||
return cnv.InitSecurityInterface_ptr();
|
return InitSecurityInterface_ptr();
|
||||||
}
|
}
|
||||||
|
|
||||||
return InitSecurityInterfaceEx(0);
|
return InitSecurityInterfaceEx(0);
|
||||||
|
@ -539,17 +539,13 @@ static long bio_rdp_tls_callback_ctrl(BIO* bio, int cmd, bio_info_cb* fp)
|
|||||||
case BIO_CTRL_SET_CALLBACK:
|
case BIO_CTRL_SET_CALLBACK:
|
||||||
{
|
{
|
||||||
typedef void (*fkt_t)(const SSL*, int, int);
|
typedef void (*fkt_t)(const SSL*, int, int);
|
||||||
|
|
||||||
/* Documented since https://www.openssl.org/docs/man1.1.1/man3/BIO_set_callback.html
|
/* Documented since https://www.openssl.org/docs/man1.1.1/man3/BIO_set_callback.html
|
||||||
* the argument is not really of type bio_info_cb* and must be cast
|
* the argument is not really of type bio_info_cb* and must be cast
|
||||||
* to the required type */
|
* to the required type */
|
||||||
union
|
|
||||||
{
|
|
||||||
fkt_t fkt;
|
|
||||||
bio_info_cb* fp;
|
|
||||||
} cnv;
|
|
||||||
|
|
||||||
cnv.fp = fp;
|
fkt_t fkt = WINPR_FUNC_PTR_CAST(fp, fkt_t);
|
||||||
SSL_set_info_callback(tls->ssl, cnv.fkt);
|
SSL_set_info_callback(tls->ssl, fkt);
|
||||||
status = 1;
|
status = 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -377,16 +377,7 @@ void primitives_init_copy(primitives_t* prims)
|
|||||||
/* Start with the default. */
|
/* Start with the default. */
|
||||||
prims->copy_8u = general_copy_8u;
|
prims->copy_8u = general_copy_8u;
|
||||||
prims->copy_8u_AC4r = general_copy_8u_AC4r;
|
prims->copy_8u_AC4r = general_copy_8u_AC4r;
|
||||||
/* This is just an alias with void* parameters
|
prims->copy = WINPR_FUNC_PTR_CAST(prims->copy_8u, __copy_t);
|
||||||
* cast with union trick to avoid -Wcast-function-type-strict
|
|
||||||
*/
|
|
||||||
union
|
|
||||||
{
|
|
||||||
__copy_8u_t ufkt;
|
|
||||||
__copy_t fkt;
|
|
||||||
} cnv;
|
|
||||||
cnv.ufkt = prims->copy_8u;
|
|
||||||
prims->copy = cnv.fkt;
|
|
||||||
prims->copy_no_overlap = generic_image_copy_no_overlap;
|
prims->copy_no_overlap = generic_image_copy_no_overlap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,21 +194,15 @@ static BOOL freerdp_client_load_static_channel_addin(rdpChannels* channels, rdpS
|
|||||||
const char* name, void* data)
|
const char* name, void* data)
|
||||||
{
|
{
|
||||||
PVIRTUALCHANNELENTRY entry = NULL;
|
PVIRTUALCHANNELENTRY entry = NULL;
|
||||||
union
|
PVIRTUALCHANNELENTRY lentry = freerdp_load_channel_addin_entry(
|
||||||
{
|
|
||||||
PVIRTUALCHANNELENTRY entry;
|
|
||||||
PVIRTUALCHANNELENTRYEX entryEx;
|
|
||||||
} cnv;
|
|
||||||
|
|
||||||
cnv.entry = freerdp_load_channel_addin_entry(
|
|
||||||
name, NULL, NULL, FREERDP_ADDIN_CHANNEL_STATIC | FREERDP_ADDIN_CHANNEL_ENTRYEX);
|
name, NULL, NULL, FREERDP_ADDIN_CHANNEL_STATIC | FREERDP_ADDIN_CHANNEL_ENTRYEX);
|
||||||
|
PVIRTUALCHANNELENTRYEX entryEx = WINPR_FUNC_PTR_CAST(lentry, PVIRTUALCHANNELENTRYEX);
|
||||||
if (!cnv.entryEx)
|
if (!entryEx)
|
||||||
entry = freerdp_load_channel_addin_entry(name, NULL, NULL, FREERDP_ADDIN_CHANNEL_STATIC);
|
entry = freerdp_load_channel_addin_entry(name, NULL, NULL, FREERDP_ADDIN_CHANNEL_STATIC);
|
||||||
|
|
||||||
if (cnv.entryEx)
|
if (entryEx)
|
||||||
{
|
{
|
||||||
if (freerdp_channels_client_load_ex(channels, settings, cnv.entryEx, data) == 0)
|
if (freerdp_channels_client_load_ex(channels, settings, entryEx, data) == 0)
|
||||||
{
|
{
|
||||||
WLog_INFO(TAG, "loading channelEx %s", name);
|
WLog_INFO(TAG, "loading channelEx %s", name);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -491,13 +491,9 @@ static BOOL pf_modules_load_module(const char* module_path, proxyModule* module,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
union
|
FARPROC fp = GetProcAddress(handle, MODULE_ENTRY_POINT);
|
||||||
{
|
proxyModuleEntryPoint pEntryPoint = WINPR_FUNC_PTR_CAST(fp, proxyModuleEntryPoint);
|
||||||
FARPROC fp;
|
if (!pEntryPoint)
|
||||||
proxyModuleEntryPoint pEntryPoint;
|
|
||||||
} cnv;
|
|
||||||
cnv.fp = GetProcAddress(handle, MODULE_ENTRY_POINT);
|
|
||||||
if (!cnv.pEntryPoint)
|
|
||||||
{
|
{
|
||||||
WLog_ERR(TAG, "GetProcAddress failed while loading %s", module_path);
|
WLog_ERR(TAG, "GetProcAddress failed while loading %s", module_path);
|
||||||
goto error;
|
goto error;
|
||||||
@ -507,7 +503,7 @@ static BOOL pf_modules_load_module(const char* module_path, proxyModule* module,
|
|||||||
WLog_ERR(TAG, "ArrayList_Append failed!");
|
WLog_ERR(TAG, "ArrayList_Append failed!");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
return pf_modules_add(module, cnv.pEntryPoint, userdata);
|
return pf_modules_add(module, pEntryPoint, userdata);
|
||||||
|
|
||||||
error:
|
error:
|
||||||
FreeLibrary(handle);
|
FreeLibrary(handle);
|
||||||
|
@ -136,4 +136,19 @@ WINPR_API const char* winpr_get_build_config(void);
|
|||||||
|
|
||||||
#define WINPR_UNUSED(x) (void)(x)
|
#define WINPR_UNUSED(x) (void)(x)
|
||||||
|
|
||||||
|
#if defined(__GNUC__) || defined(__clang__)
|
||||||
|
#define WINPR_FUNC_PTR_CAST(ptr, dstType) \
|
||||||
|
({ \
|
||||||
|
union \
|
||||||
|
{ \
|
||||||
|
typeof(ptr) src; \
|
||||||
|
dstType dst; \
|
||||||
|
} cnv; \
|
||||||
|
cnv.src = ptr; \
|
||||||
|
cnv.dst; \
|
||||||
|
})
|
||||||
|
#else
|
||||||
|
#define WINPR_FUNC_PTR_CAST(ptr, dstType) (dstType)(uintptr_t) ptr
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* WINPR_H */
|
#endif /* WINPR_H */
|
||||||
|
@ -47,13 +47,13 @@ int TestLibraryGetProcAddress(int argc, char* argv[])
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(pFunctionA = (TEST_AB_FN)GetProcAddress(library, "FunctionA")))
|
if (!(pFunctionA = WINPR_FUNC_PTR_CAST(GetProcAddress(library, "FunctionA"), TEST_AB_FN)))
|
||||||
{
|
{
|
||||||
printf("%s: GetProcAddress failure (FunctionA)\n", __func__);
|
printf("%s: GetProcAddress failure (FunctionA)\n", __func__);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(pFunctionB = (TEST_AB_FN)GetProcAddress(library, "FunctionB")))
|
if (!(pFunctionB = WINPR_FUNC_PTR_CAST(GetProcAddress(library, "FunctionB"), TEST_AB_FN)))
|
||||||
{
|
{
|
||||||
printf("%s: GetProcAddress failure (FunctionB)\n", __func__);
|
printf("%s: GetProcAddress failure (FunctionB)\n", __func__);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -267,15 +267,15 @@ SECURITY_STATUS winpr_NCryptOpenStorageProviderEx(NCRYPT_PROV_HANDLE* phProvider
|
|||||||
{
|
{
|
||||||
typedef SECURITY_STATUS (*NCryptOpenStorageProviderFn)(NCRYPT_PROV_HANDLE * phProvider,
|
typedef SECURITY_STATUS (*NCryptOpenStorageProviderFn)(NCRYPT_PROV_HANDLE * phProvider,
|
||||||
LPCWSTR pszProviderName, DWORD dwFlags);
|
LPCWSTR pszProviderName, DWORD dwFlags);
|
||||||
NCryptOpenStorageProviderFn ncryptOpenStorageProviderFn;
|
SECURITY_STATUS ret = NTE_PROV_DLL_NOT_FOUND;
|
||||||
SECURITY_STATUS ret;
|
|
||||||
HANDLE lib = LoadLibraryA("ncrypt.dll");
|
HANDLE lib = LoadLibraryA("ncrypt.dll");
|
||||||
if (!lib)
|
if (!lib)
|
||||||
return NTE_PROV_DLL_NOT_FOUND;
|
return NTE_PROV_DLL_NOT_FOUND;
|
||||||
|
|
||||||
ncryptOpenStorageProviderFn =
|
FARPROC fp = GetProcAddress(lib, "NCryptOpenStorageProvider");
|
||||||
(NCryptOpenStorageProviderFn)GetProcAddress(lib, "NCryptOpenStorageProvider");
|
NCryptOpenStorageProviderFn ncryptOpenStorageProviderFn =
|
||||||
if (!ncryptOpenStorageProviderFn)
|
WINPR_FUNC_PTR_CAST(fp, NCryptOpenStorageProviderFn);
|
||||||
|
(NCryptOpenStorageProviderFn) if (!ncryptOpenStorageProviderFn)
|
||||||
{
|
{
|
||||||
ret = NTE_PROV_DLL_NOT_FOUND;
|
ret = NTE_PROV_DLL_NOT_FOUND;
|
||||||
goto out_free_lib;
|
goto out_free_lib;
|
||||||
|
@ -1261,20 +1261,16 @@ SECURITY_STATUS NCryptOpenP11StorageProviderEx(NCRYPT_PROV_HANDLE* phProvider,
|
|||||||
goto out_load_library;
|
goto out_load_library;
|
||||||
}
|
}
|
||||||
|
|
||||||
union
|
FARPROC fp = GetProcAddress(library, "C_GetFunctionList");
|
||||||
{
|
c_get_function_list_t c_get_function_list = WINPR_FUNC_PTR_CAST(fp, c_get_function_list_t);
|
||||||
FARPROC fp;
|
|
||||||
c_get_function_list_t c_get_function_list;
|
|
||||||
} cnv;
|
|
||||||
cnv.fp = GetProcAddress(library, "C_GetFunctionList");
|
|
||||||
|
|
||||||
if (!cnv.c_get_function_list)
|
if (!c_get_function_list)
|
||||||
{
|
{
|
||||||
status = NTE_PROV_TYPE_ENTRY_BAD;
|
status = NTE_PROV_TYPE_ENTRY_BAD;
|
||||||
goto out_load_library;
|
goto out_load_library;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = initialize_pkcs11(library, cnv.c_get_function_list, phProvider);
|
status = initialize_pkcs11(library, c_get_function_list, phProvider);
|
||||||
if (status != ERROR_SUCCESS)
|
if (status != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
status = NTE_PROVIDER_DLL_FAIL;
|
status = NTE_PROVIDER_DLL_FAIL;
|
||||||
|
@ -26,15 +26,17 @@
|
|||||||
#ifdef WINPR_THREAD_POOL
|
#ifdef WINPR_THREAD_POOL
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
typedef BOOL(WINAPI* pCallbackMayRunLong_t)(PTP_CALLBACK_INSTANCE pci);
|
||||||
static INIT_ONCE init_once_module = INIT_ONCE_STATIC_INIT;
|
static INIT_ONCE init_once_module = INIT_ONCE_STATIC_INIT;
|
||||||
static BOOL(WINAPI* pCallbackMayRunLong)(PTP_CALLBACK_INSTANCE pci);
|
static pCallbackMayRunLong_t pCallbackMayRunLong = NULL;
|
||||||
|
|
||||||
static BOOL CALLBACK init_module(PINIT_ONCE once, PVOID param, PVOID* context)
|
static BOOL CALLBACK init_module(PINIT_ONCE once, PVOID param, PVOID* context)
|
||||||
{
|
{
|
||||||
HMODULE kernel32 = LoadLibraryA("kernel32.dll");
|
HMODULE kernel32 = LoadLibraryA("kernel32.dll");
|
||||||
if (kernel32)
|
if (kernel32)
|
||||||
{
|
{
|
||||||
pCallbackMayRunLong = (void*)GetProcAddress(kernel32, "CallbackMayRunLong");
|
FARPROC fp = GetProcAddress(kernel32, "CallbackMayRunLong");
|
||||||
|
pCallbackMayRunLong = WINPR_FUNC_PTR_CAST(fp, pCallbackMayRunLong_t);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -1100,13 +1100,14 @@ WINSCARDAPI char* WINAPI SCardGetReaderStateString(DWORD dwReaderState)
|
|||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define WINSCARD_LOAD_PROC(_name, ...) \
|
#define WINSCARD_LOAD_PROC(_name, ...) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
WINPR_PRAGMA_DIAG_PUSH \
|
WINPR_PRAGMA_DIAG_PUSH \
|
||||||
WINPR_PRAGMA_DIAG_IGNORED_PEDANTIC \
|
WINPR_PRAGMA_DIAG_IGNORED_PEDANTIC \
|
||||||
pWinSCardApiTable->pfn##_name = (fn##_name)GetProcAddress(hWinSCardLibrary, #_name); \
|
FARPROC fp = GetProcAddress(hWinSCardLibrary, #_name); \
|
||||||
WINPR_PRAGMA_DIAG_POP \
|
pWinSCardApiTable->pfn##_name = WINPR_FUNC_PTR_CAST(fp, fn##_name); \
|
||||||
|
WINPR_PRAGMA_DIAG_POP \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
BOOL WinSCard_LoadApiTableFunctions(PSCardApiFunctionTable pWinSCardApiTable,
|
BOOL WinSCard_LoadApiTableFunctions(PSCardApiFunctionTable pWinSCardApiTable,
|
||||||
|
@ -48,13 +48,13 @@
|
|||||||
#include "../log.h"
|
#include "../log.h"
|
||||||
#define TAG WINPR_TAG("smartcard")
|
#define TAG WINPR_TAG("smartcard")
|
||||||
|
|
||||||
#define WINSCARD_LOAD_PROC_EX(module, pcsc, _fname, _name, ...) \
|
#define WINSCARD_LOAD_PROC_EX(module, pcsc, _fname, _name, ...) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
WINPR_PRAGMA_DIAG_PUSH \
|
WINPR_PRAGMA_DIAG_PUSH \
|
||||||
WINPR_PRAGMA_DIAG_IGNORED_PEDANTIC \
|
WINPR_PRAGMA_DIAG_IGNORED_PEDANTIC \
|
||||||
pcsc.pfn##_fname = (fnPCSC##_fname)GetProcAddress(module, #_name); \
|
pcsc.pfn##_fname = WINPR_FUNC_PTR_CAST(GetProcAddress(module, #_name), fnPCSC##_fname); \
|
||||||
WINPR_PRAGMA_DIAG_POP \
|
WINPR_PRAGMA_DIAG_POP \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define WINSCARD_LOAD_PROC(module, pcsc, _name, ...) \
|
#define WINSCARD_LOAD_PROC(module, pcsc, _name, ...) \
|
||||||
|
@ -107,10 +107,10 @@ BOOL InitializeSspiModule_Native(void)
|
|||||||
if (!g_SspiModule)
|
if (!g_SspiModule)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
pInitSecurityInterfaceW =
|
pInitSecurityInterfaceW = WINPR_FUNC_PTR_CAST(
|
||||||
(INIT_SECURITY_INTERFACE_W)GetProcAddress(g_SspiModule, "InitSecurityInterfaceW");
|
GetProcAddress(g_SspiModule, "InitSecurityInterfaceW"), INIT_SECURITY_INTERFACE_W);
|
||||||
pInitSecurityInterfaceA =
|
pInitSecurityInterfaceA = WINPR_FUNC_PTR_CAST(
|
||||||
(INIT_SECURITY_INTERFACE_A)GetProcAddress(g_SspiModule, "InitSecurityInterfaceA");
|
GetProcAddress(g_SspiModule, "InitSecurityInterfaceA"), INIT_SECURITY_INTERFACE_A);
|
||||||
|
|
||||||
if (pInitSecurityInterfaceW)
|
if (pInitSecurityInterfaceW)
|
||||||
{
|
{
|
||||||
@ -124,11 +124,12 @@ BOOL InitializeSspiModule_Native(void)
|
|||||||
|
|
||||||
g_SspiW->dwVersion = SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION_3;
|
g_SspiW->dwVersion = SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION_3;
|
||||||
|
|
||||||
g_SspiW->SetContextAttributesW =
|
g_SspiW->SetContextAttributesW = WINPR_FUNC_PTR_CAST(
|
||||||
(SET_CONTEXT_ATTRIBUTES_FN_W)GetProcAddress(g_SspiModule, "SetContextAttributesW");
|
GetProcAddress(g_SspiModule, "SetContextAttributesW"), SET_CONTEXT_ATTRIBUTES_FN_W);
|
||||||
|
|
||||||
g_SspiW->SetCredentialsAttributesW = (SET_CREDENTIALS_ATTRIBUTES_FN_W)GetProcAddress(
|
g_SspiW->SetCredentialsAttributesW =
|
||||||
g_SspiModule, "SetCredentialsAttributesW");
|
WINPR_FUNC_PTR_CAST(GetProcAddress(g_SspiModule, "SetCredentialsAttributesW"),
|
||||||
|
SET_CREDENTIALS_ATTRIBUTES_FN_W);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,11 +145,12 @@ BOOL InitializeSspiModule_Native(void)
|
|||||||
|
|
||||||
g_SspiA->dwVersion = SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION_3;
|
g_SspiA->dwVersion = SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION_3;
|
||||||
|
|
||||||
g_SspiA->SetContextAttributesA =
|
g_SspiA->SetContextAttributesA = WINPR_FUNC_PTR_CAST(
|
||||||
(SET_CONTEXT_ATTRIBUTES_FN_W)GetProcAddress(g_SspiModule, "SetContextAttributesA");
|
GetProcAddress(g_SspiModule, "SetContextAttributesA"), SET_CONTEXT_ATTRIBUTES_FN_W);
|
||||||
|
|
||||||
g_SspiA->SetCredentialsAttributesA = (SET_CREDENTIALS_ATTRIBUTES_FN_W)GetProcAddress(
|
g_SspiA->SetCredentialsAttributesA =
|
||||||
g_SspiModule, "SetCredentialsAttributesA");
|
WINPR_FUNC_PTR_CAST(GetProcAddress(g_SspiModule, "SetCredentialsAttributesA"),
|
||||||
|
SET_CREDENTIALS_ATTRIBUTES_FN_W);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,12 +70,14 @@ static BOOL CALLBACK InitOnce_Barrier(PINIT_ONCE once, PVOID param, PVOID* conte
|
|||||||
pfnInitializeSynchronizationBarrier = (fnInitializeSynchronizationBarrier)GetProcAddress(
|
pfnInitializeSynchronizationBarrier = (fnInitializeSynchronizationBarrier)GetProcAddress(
|
||||||
g_Kernel32, "InitializeSynchronizationBarrier");
|
g_Kernel32, "InitializeSynchronizationBarrier");
|
||||||
|
|
||||||
pfnEnterSynchronizationBarrier =
|
{
|
||||||
(fnEnterSynchronizationBarrier)GetProcAddress(g_Kernel32, "EnterSynchronizationBarrier");
|
FARPROC fp = GetProcAddress(g_Kernel32, "EnterSynchronizationBarrier");
|
||||||
|
pfnEnterSynchronizationBarrier = WINPR_FUNC_PTR_CAST(fp, fnEnterSynchronizationBarrier);
|
||||||
pfnDeleteSynchronizationBarrier =
|
}
|
||||||
(fnDeleteSynchronizationBarrier)GetProcAddress(g_Kernel32, "DeleteSynchronizationBarrier");
|
{
|
||||||
|
FARPROC fp = GetProcAddress(g_Kernel32, "DeleteSynchronizationBarrier");
|
||||||
|
pfnDeleteSynchronizationBarrier = WINPR_FUNC_PTR_CAST(fp, fnDeleteSynchronizationBarrier);
|
||||||
|
}
|
||||||
if (pfnInitializeSynchronizationBarrier && pfnEnterSynchronizationBarrier &&
|
if (pfnInitializeSynchronizationBarrier && pfnEnterSynchronizationBarrier &&
|
||||||
pfnDeleteSynchronizationBarrier)
|
pfnDeleteSynchronizationBarrier)
|
||||||
{
|
{
|
||||||
|
@ -700,17 +700,13 @@ static BOOL LoadAndInitialize(char* library)
|
|||||||
if (!g_WtsApiModule)
|
if (!g_WtsApiModule)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
union
|
FARPROC fp = GetProcAddress(g_WtsApiModule, "InitWtsApi");
|
||||||
{
|
INIT_WTSAPI_FN pInitWtsApi = WINPR_FUNC_PTR_CAST(fp, INIT_WTSAPI_FN);
|
||||||
FARPROC fp;
|
|
||||||
INIT_WTSAPI_FN pInitWtsApi;
|
|
||||||
} cnv;
|
|
||||||
cnv.fp = GetProcAddress(g_WtsApiModule, "InitWtsApi");
|
|
||||||
|
|
||||||
if (!cnv.pInitWtsApi)
|
if (!pInitWtsApi)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
g_WtsApi = cnv.pInitWtsApi();
|
g_WtsApi = pInitWtsApi();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user