[function pointer] use macro for GetProcAddress

Cast all results of GetProcAddress with WINPR_FUNC_PTR_CAST
This commit is contained in:
akallabeth 2024-09-04 19:02:51 +02:00
parent 889ae65a1f
commit 6a1c3b4545
No known key found for this signature in database
GPG Key ID: A49454A3FC909FD5
25 changed files with 101 additions and 103 deletions

View File

@ -22,6 +22,7 @@
#include <freerdp/config.h>
#include <winpr/windows.h>
#include <winpr/library.h>
#include <winpr/crt.h>
#include <winpr/assert.h>
@ -1396,9 +1397,9 @@ static int wfreerdp_client_start(rdpContext* context)
if (module)
{
GetDpiForWindow_t pGetDpiForWindow =
(GetDpiForWindow_t)GetProcAddress(module, "GetDpiForWindow");
GetProcAddressAs(module, "GetDpiForWindow", GetDpiForWindow_t);
SetProcessDPIAware_t pSetProcessDPIAware =
(SetProcessDPIAware_t)GetProcAddress(module, "SetProcessDPIAware");
GetProcAddressAs(module, "SetProcessDPIAware", SetProcessDPIAware_t);
if (pGetDpiForWindow && pSetProcessDPIAware)
{
const UINT dpiAwareness = pGetDpiForWindow(hWndParent);

View File

@ -31,6 +31,7 @@
#include <winuser.h>
#include <winpr/assert.h>
#include <winpr/library.h>
#include <winpr/crt.h>
#include <winpr/tchar.h>
@ -2473,12 +2474,12 @@ BOOL wf_cliprdr_init(wfContext* wfc, CliprdrClientContext* cliprdr)
if (clipboard->hUser32)
{
clipboard->AddClipboardFormatListener = (fnAddClipboardFormatListener)GetProcAddress(
clipboard->hUser32, "AddClipboardFormatListener");
clipboard->RemoveClipboardFormatListener = (fnRemoveClipboardFormatListener)GetProcAddress(
clipboard->hUser32, "RemoveClipboardFormatListener");
clipboard->GetUpdatedClipboardFormats = (fnGetUpdatedClipboardFormats)GetProcAddress(
clipboard->hUser32, "GetUpdatedClipboardFormats");
clipboard->AddClipboardFormatListener = GetProcAddressAs(
clipboard->hUser32, "AddClipboardFormatListener", fnAddClipboardFormatListener);
clipboard->RemoveClipboardFormatListener = GetProcAddressAs(
clipboard->hUser32, "RemoveClipboardFormatListener", fnRemoveClipboardFormatListener);
clipboard->GetUpdatedClipboardFormats = GetProcAddressAs(
clipboard->hUser32, "GetUpdatedClipboardFormats", fnGetUpdatedClipboardFormats);
}
if (!(clipboard->hUser32 && clipboard->AddClipboardFormatListener &&

View File

@ -17,6 +17,7 @@
* limitations under the License.
*/
#include <winpr/winpr.h>
#include <freerdp/log.h>
#include <freerdp/codec/h264.h>
@ -466,12 +467,13 @@ static BOOL mf_init(H264_CONTEXT* h264)
if (!sys->mfplat)
goto error;
sys->MFStartup = (pfnMFStartup)GetProcAddress(sys->mfplat, "MFStartup");
sys->MFShutdown = (pfnMFShutdown)GetProcAddress(sys->mfplat, "MFShutdown");
sys->MFCreateSample = (pfnMFCreateSample)GetProcAddress(sys->mfplat, "MFCreateSample");
sys->MFStartup = GetProcAddressAs(sys->mfplat, "MFStartup", pfnMFStartup);
sys->MFShutdown = GetProcAddressAs(sys->mfplat, "MFShutdown", pfnMFShutdown);
sys->MFCreateSample = GetProcAddressAs(sys->mfplat, "MFCreateSample", pfnMFCreateSample);
sys->MFCreateMemoryBuffer =
(pfnMFCreateMemoryBuffer)GetProcAddress(sys->mfplat, "MFCreateMemoryBuffer");
sys->MFCreateMediaType = (pfnMFCreateMediaType)GetProcAddress(sys->mfplat, "MFCreateMediaType");
GetProcAddressAs(sys->mfplat, "MFCreateMemoryBuffer", pfnMFCreateMemoryBuffer);
sys->MFCreateMediaType =
GetProcAddressAs(sys->mfplat, "MFCreateMediaType", pfnMFCreateMediaType);
if (!mf_plat_loaded(sys))
goto error;

View File

@ -467,15 +467,15 @@ static BOOL openh264_load_functionpointers(H264_CONTEXT* h264, const char* name)
return FALSE;
sysContexts->WelsGetCodecVersionEx =
(pWelsGetCodecVersionEx)GetProcAddress(sysContexts->lib, "WelsGetCodecVersionEx");
GetProcAddressAs(sysContexts->lib, "WelsGetCodecVersionEx", pWelsGetCodecVersionEx);
sysContexts->WelsCreateDecoder =
(pWelsCreateDecoder)GetProcAddress(sysContexts->lib, "WelsCreateDecoder");
GetProcAddressAs(sysContexts->lib, "WelsCreateDecoder", pWelsCreateDecoder);
sysContexts->WelsDestroyDecoder =
(pWelsDestroyDecoder)GetProcAddress(sysContexts->lib, "WelsDestroyDecoder");
GetProcAddressAs(sysContexts->lib, "WelsDestroyDecoder", pWelsDestroyDecoder);
sysContexts->WelsCreateSVCEncoder =
(pWelsCreateSVCEncoder)GetProcAddress(sysContexts->lib, "WelsCreateSVCEncoder");
GetProcAddressAs(sysContexts->lib, "WelsCreateSVCEncoder", pWelsCreateSVCEncoder);
sysContexts->WelsDestroySVCEncoder =
(pWelsDestroySVCEncoder)GetProcAddress(sysContexts->lib, "WelsDestroySVCEncoder");
GetProcAddressAs(sysContexts->lib, "WelsDestroySVCEncoder", pWelsDestroySVCEncoder);
if (!sysContexts->WelsCreateDecoder || !sysContexts->WelsDestroyDecoder ||
!sysContexts->WelsCreateSVCEncoder || !sysContexts->WelsDestroySVCEncoder ||

View File

@ -237,8 +237,7 @@ PVIRTUALCHANNELENTRY freerdp_load_dynamic_addin(LPCSTR pszFileName, LPCSTR pszPa
if (!library)
goto fail;
FARPROC fp = GetProcAddress(library, pszEntryName);
entry = WINPR_FUNC_PTR_CAST(fp, PVIRTUALCHANNELENTRY);
entry = GetProcAddressAs(library, pszEntryName, PVIRTUALCHANNELENTRY);
fail:
free(pszRelativeFilePath);
free(pszAddinFile);

View File

@ -470,9 +470,8 @@ static BOOL createChildSessionTransport(HANDLE* pFile)
WCHAR pipePath[0x80] = { 0 };
char pipePathA[0x80] = { 0 };
FARPROC fp = GetProcAddress(hModule, "WinStationCreateChildSessionTransport");
WinStationCreateChildSessionTransportFn createChildSessionFn =
WINPR_FUNC_PTR_CAST(fp, WinStationCreateChildSessionTransportFn);
WinStationCreateChildSessionTransportFn createChildSessionFn = GetProcAddressAs(
hModule, "WinStationCreateChildSessionTransport", WinStationCreateChildSessionTransportFn);
if (!createChildSessionFn)
{
WLog_ERR(TAG, "unable to retrieve WinStationCreateChildSessionTransport function");

View File

@ -814,9 +814,8 @@ static SecurityFunctionTable* auth_resolve_sspi_table(const rdpSettings* setting
WLog_INFO(TAG, "Using SSPI Module: %s", module_name);
FARPROC fp = GetProcAddress(hSSPI, proc_name);
INIT_SECURITY_INTERFACE InitSecurityInterface_ptr =
WINPR_FUNC_PTR_CAST(fp, INIT_SECURITY_INTERFACE);
GetProcAddressAs(hSSPI, proc_name, INIT_SECURITY_INTERFACE);
if (!InitSecurityInterface_ptr)
{
WLog_ERR(TAG, "Failed to load SSPI module: %s, no function %s", module_name, proc_name);

View File

@ -491,8 +491,8 @@ static BOOL pf_modules_load_module(const char* module_path, proxyModule* module,
return FALSE;
}
FARPROC fp = GetProcAddress(handle, MODULE_ENTRY_POINT);
proxyModuleEntryPoint pEntryPoint = WINPR_FUNC_PTR_CAST(fp, proxyModuleEntryPoint);
proxyModuleEntryPoint pEntryPoint =
GetProcAddressAs(handle, MODULE_ENTRY_POINT, proxyModuleEntryPoint);
if (!pEntryPoint)
{
WLog_ERR(TAG, "GetProcAddress failed while loading %s", module_path);

View File

@ -20,6 +20,7 @@
#include <winpr/crt.h>
#include <winpr/print.h>
#include <winpr/library.h>
#include <freerdp/log.h>
#include "win_dxgi.h"
@ -288,7 +289,7 @@ static void win_shadow_d3d11_module_init()
if (!d3d11_module)
return;
pfnD3D11CreateDevice = (fnD3D11CreateDevice)GetProcAddress(d3d11_module, "D3D11CreateDevice");
pfnD3D11CreateDevice = GetProcAddressAs(d3d11_module, "D3D11CreateDevice", fnD3D11CreateDevice);
}
int win_shadow_dxgi_init_duplication(winShadowSubsystem* subsystem)

View File

@ -85,6 +85,8 @@ extern "C"
}
#endif
#define GetProcAddressAs(module, name, type) WINPR_FUNC_PTR_CAST(GetProcAddress(module, name), type)
#if !defined(_WIN32) && !defined(__CYGWIN__)
#ifdef __cplusplus

View File

@ -160,7 +160,7 @@ WINPR_API const char* winpr_get_build_config(void);
})
#else
#define WINPR_CAST_CONST_PTR_AWAY(ptr, dstType) (dstType) ptr
#define WINPR_CONST_PTR_AWAY_CAST(ptr, dstType) (dstType)(uintptr_t) ptr
#define WINPR_FUNC_PTR_CAST(ptr, dstType) (dstType)(uintptr_t) ptr
#endif
#endif /* WINPR_H */

View File

@ -47,13 +47,13 @@ int TestLibraryGetProcAddress(int argc, char* argv[])
return -1;
}
if (!(pFunctionA = WINPR_FUNC_PTR_CAST(GetProcAddress(library, "FunctionA"), TEST_AB_FN)))
if (!(pFunctionA = GetProcAddressAs(library, "FunctionA", TEST_AB_FN)))
{
printf("%s: GetProcAddress failure (FunctionA)\n", __func__);
return -1;
}
if (!(pFunctionB = WINPR_FUNC_PTR_CAST(GetProcAddress(library, "FunctionB"), TEST_AB_FN)))
if (!(pFunctionB = GetProcAddressAs(library, "FunctionB", TEST_AB_FN)))
{
printf("%s: GetProcAddress failure (FunctionB)\n", __func__);
return -1;

View File

@ -18,6 +18,7 @@
*/
#include <winpr/assert.h>
#include <winpr/library.h>
#include <winpr/ncrypt.h>
#ifndef _WIN32
@ -272,10 +273,9 @@ SECURITY_STATUS winpr_NCryptOpenStorageProviderEx(NCRYPT_PROV_HANDLE* phProvider
if (!lib)
return NTE_PROV_DLL_NOT_FOUND;
FARPROC fp = GetProcAddress(lib, "NCryptOpenStorageProvider");
NCryptOpenStorageProviderFn ncryptOpenStorageProviderFn =
WINPR_FUNC_PTR_CAST(fp, NCryptOpenStorageProviderFn);
(NCryptOpenStorageProviderFn) if (!ncryptOpenStorageProviderFn)
GetProcAddressAs(lib, "NCryptOpenStorageProvider", NCryptOpenStorageProviderFn);
if (!ncryptOpenStorageProviderFn)
{
ret = NTE_PROV_DLL_NOT_FOUND;
goto out_free_lib;

View File

@ -1261,8 +1261,8 @@ SECURITY_STATUS NCryptOpenP11StorageProviderEx(NCRYPT_PROV_HANDLE* phProvider,
goto out_load_library;
}
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);
c_get_function_list_t c_get_function_list =
GetProcAddressAs(library, "C_GetFunctionList", c_get_function_list_t);
if (!c_get_function_list)
{

View File

@ -34,10 +34,8 @@ static BOOL CALLBACK init_module(PINIT_ONCE once, PVOID param, PVOID* context)
{
HMODULE kernel32 = LoadLibraryA("kernel32.dll");
if (kernel32)
{
FARPROC fp = GetProcAddress(kernel32, "CallbackMayRunLong");
pCallbackMayRunLong = WINPR_FUNC_PTR_CAST(fp, pCallbackMayRunLong_t);
}
pCallbackMayRunLong =
GetProcAddressAs(kernel32, "CallbackMayRunLong", pCallbackMayRunLong_t);
return TRUE;
}
#endif

View File

@ -44,17 +44,17 @@ static BOOL CALLBACK init_module(PINIT_ONCE once, PVOID param, PVOID* context)
if (kernel32)
{
pSetEventWhenCallbackReturns =
(void*)GetProcAddress(kernel32, "SetEventWhenCallbackReturns");
GetProcAddressAs(kernel32, "SetEventWhenCallbackReturns"), void*);
pReleaseSemaphoreWhenCallbackReturns =
(void*)GetProcAddress(kernel32, "ReleaseSemaphoreWhenCallbackReturns");
GetProcAddressAs(kernel32, "ReleaseSemaphoreWhenCallbackReturns", void*);
pReleaseMutexWhenCallbackReturns =
(void*)GetProcAddress(kernel32, "ReleaseMutexWhenCallbackReturns");
GetProcAddressAs(kernel32, "ReleaseMutexWhenCallbackReturns", void*);
pLeaveCriticalSectionWhenCallbackReturns =
(void*)GetProcAddress(kernel32, "LeaveCriticalSectionWhenCallbackReturns");
GetProcAddressAs(kernel32, "LeaveCriticalSectionWhenCallbackReturns", void*);
pFreeLibraryWhenCallbackReturns =
(void*)GetProcAddress(kernel32, "FreeLibraryWhenCallbackReturns");
GetProcAddressAs(kernel32, "FreeLibraryWhenCallbackReturns", void*);
pDisassociateCurrentThreadFromCallback =
(void*)GetProcAddress(kernel32, "DisassociateCurrentThreadFromCallback");
GetProcAddressAs(kernel32, "DisassociateCurrentThreadFromCallback", void*);
}
return TRUE;
}

View File

@ -19,6 +19,7 @@
#include <winpr/config.h>
#include <winpr/winpr.h>
#include <winpr/crt.h>
#include <winpr/pool.h>
#include <winpr/library.h>
@ -42,11 +43,11 @@ static BOOL CALLBACK init_module(PINIT_ONCE once, PVOID param, PVOID* context)
if (kernel32)
{
pCreateThreadpoolCleanupGroup =
(void*)GetProcAddress(kernel32, "CreateThreadpoolCleanupGroup");
GetProcAddressAs(kernel32, "CreateThreadpoolCleanupGroup", void*);
pCloseThreadpoolCleanupGroupMembers =
(void*)GetProcAddress(kernel32, "CloseThreadpoolCleanupGroupMembers");
GetProcAddressAs(kernel32, "CloseThreadpoolCleanupGroupMembers", void*);
pCloseThreadpoolCleanupGroup =
(void*)GetProcAddress(kernel32, "CloseThreadpoolCleanupGroup");
GetProcAddressAs(kernel32, "CloseThreadpoolCleanupGroup", void*);
}
return TRUE;

View File

@ -40,10 +40,12 @@ static BOOL CALLBACK init_module(PINIT_ONCE once, PVOID param, PVOID* context)
HMODULE kernel32 = LoadLibraryA("kernel32.dll");
if (kernel32)
{
pCreateThreadpool = (void*)GetProcAddress(kernel32, "CreateThreadpool");
pCloseThreadpool = (void*)GetProcAddress(kernel32, "CloseThreadpool");
pSetThreadpoolThreadMinimum = (void*)GetProcAddress(kernel32, "SetThreadpoolThreadMinimum");
pSetThreadpoolThreadMaximum = (void*)GetProcAddress(kernel32, "SetThreadpoolThreadMaximum");
pCreateThreadpool = GetProcAddressAs(kernel32, "CreateThreadpool", void*);
pCloseThreadpool = GetProcAddressAs(kernel32, "CloseThreadpool", void*);
pSetThreadpoolThreadMinimum =
GetProcAddressAs(kernel32, "SetThreadpoolThreadMinimum", void*);
pSetThreadpoolThreadMaximum =
GetProcAddressAs(kernel32, "SetThreadpoolThreadMaximum", void*);
}
return TRUE;
}

View File

@ -46,13 +46,13 @@ static BOOL CALLBACK init_module(PINIT_ONCE once, PVOID param, PVOID* context)
if (kernel32)
{
pCreateThreadpoolWork = (void*)GetProcAddress(kernel32, "CreateThreadpoolWork");
pCloseThreadpoolWork = (void*)GetProcAddress(kernel32, "CloseThreadpoolWork");
pSubmitThreadpoolWork = (void*)GetProcAddress(kernel32, "SubmitThreadpoolWork");
pCreateThreadpoolWork = GetProcAddressAs(kernel32, "CreateThreadpoolWork", void*);
pCloseThreadpoolWork = GetProcAddressAs(kernel32, "CloseThreadpoolWork", void*);
pSubmitThreadpoolWork = GetProcAddressAs(kernel32, "SubmitThreadpoolWork", void*);
pTrySubmitThreadpoolCallback =
(void*)GetProcAddress(kernel32, "TrySubmitThreadpoolCallback");
GetProcAddressAs(kernel32, "TrySubmitThreadpoolCallback", void*);
pWaitForThreadpoolWorkCallbacks =
(void*)GetProcAddress(kernel32, "WaitForThreadpoolWorkCallbacks");
GetProcAddressAs(kernel32, "WaitForThreadpoolWorkCallbacks", void*);
}
return TRUE;

View File

@ -1105,8 +1105,7 @@ WINSCARDAPI char* WINAPI SCardGetReaderStateString(DWORD dwReaderState)
{ \
WINPR_PRAGMA_DIAG_PUSH \
WINPR_PRAGMA_DIAG_IGNORED_PEDANTIC \
FARPROC fp = GetProcAddress(hWinSCardLibrary, #_name); \
pWinSCardApiTable->pfn##_name = WINPR_FUNC_PTR_CAST(fp, fn##_name); \
pWinSCardApiTable->pfn##_name = GetProcAddressAs(hWinSCardLibrary, #_name, fn##_name); \
WINPR_PRAGMA_DIAG_POP \
} while (0)

View File

@ -53,7 +53,7 @@
{ \
WINPR_PRAGMA_DIAG_PUSH \
WINPR_PRAGMA_DIAG_IGNORED_PEDANTIC \
pcsc.pfn##_fname = WINPR_FUNC_PTR_CAST(GetProcAddress(module, #_name), fnPCSC##_fname); \
pcsc.pfn##_fname = GetProcAddressAs(module, #_name, fnPCSC##_fname); \
WINPR_PRAGMA_DIAG_POP \
} while (0)

View File

@ -107,10 +107,10 @@ BOOL InitializeSspiModule_Native(void)
if (!g_SspiModule)
return FALSE;
pInitSecurityInterfaceW = WINPR_FUNC_PTR_CAST(
GetProcAddress(g_SspiModule, "InitSecurityInterfaceW"), INIT_SECURITY_INTERFACE_W);
pInitSecurityInterfaceA = WINPR_FUNC_PTR_CAST(
GetProcAddress(g_SspiModule, "InitSecurityInterfaceA"), INIT_SECURITY_INTERFACE_A);
pInitSecurityInterfaceW =
GetProcAddressAs(g_SspiModule, "InitSecurityInterfaceW", INIT_SECURITY_INTERFACE_W);
pInitSecurityInterfaceA =
GetProcAddressAs(g_SspiModule, "InitSecurityInterfaceA", INIT_SECURITY_INTERFACE_A);
if (pInitSecurityInterfaceW)
{
@ -124,12 +124,11 @@ BOOL InitializeSspiModule_Native(void)
g_SspiW->dwVersion = SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION_3;
g_SspiW->SetContextAttributesW = WINPR_FUNC_PTR_CAST(
GetProcAddress(g_SspiModule, "SetContextAttributesW"), SET_CONTEXT_ATTRIBUTES_FN_W);
g_SspiW->SetContextAttributesW = GetProcAddressAs(g_SspiModule, "SetContextAttributesW",
SET_CONTEXT_ATTRIBUTES_FN_W);
g_SspiW->SetCredentialsAttributesW =
WINPR_FUNC_PTR_CAST(GetProcAddress(g_SspiModule, "SetCredentialsAttributesW"),
SET_CREDENTIALS_ATTRIBUTES_FN_W);
g_SspiW->SetCredentialsAttributesW = GetProcAddressAs(
g_SspiModule, "SetCredentialsAttributesW", SET_CREDENTIALS_ATTRIBUTES_FN_W);
}
}
@ -145,12 +144,11 @@ BOOL InitializeSspiModule_Native(void)
g_SspiA->dwVersion = SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION_3;
g_SspiA->SetContextAttributesA = WINPR_FUNC_PTR_CAST(
GetProcAddress(g_SspiModule, "SetContextAttributesA"), SET_CONTEXT_ATTRIBUTES_FN_W);
g_SspiA->SetContextAttributesA = GetProcAddressAs(g_SspiModule, "SetContextAttributesA",
SET_CONTEXT_ATTRIBUTES_FN_W);
g_SspiA->SetCredentialsAttributesA =
WINPR_FUNC_PTR_CAST(GetProcAddress(g_SspiModule, "SetCredentialsAttributesA"),
SET_CREDENTIALS_ATTRIBUTES_FN_W);
g_SspiA->SetCredentialsAttributesA = GetProcAddressAs(
g_SspiModule, "SetCredentialsAttributesA", SET_CREDENTIALS_ATTRIBUTES_FN_W);
}
}

View File

@ -67,17 +67,14 @@ static BOOL CALLBACK InitOnce_Barrier(PINIT_ONCE once, PVOID param, PVOID* conte
if (!g_Kernel32)
return TRUE;
pfnInitializeSynchronizationBarrier = (fnInitializeSynchronizationBarrier)GetProcAddress(
g_Kernel32, "InitializeSynchronizationBarrier");
pfnInitializeSynchronizationBarrier = GetProcAddressAs(
g_Kernel32, "InitializeSynchronizationBarrier", fnInitializeSynchronizationBarrier);
pfnEnterSynchronizationBarrier =
GetProcAddressAs(g_Kernel32, "EnterSynchronizationBarrier", fnEnterSynchronizationBarrier);
pfnDeleteSynchronizationBarrier = GetProcAddressAs(g_Kernel32, "DeleteSynchronizationBarrier",
fnDeleteSynchronizationBarrier);
{
FARPROC fp = GetProcAddress(g_Kernel32, "EnterSynchronizationBarrier");
pfnEnterSynchronizationBarrier = WINPR_FUNC_PTR_CAST(fp, fnEnterSynchronizationBarrier);
}
{
FARPROC fp = GetProcAddress(g_Kernel32, "DeleteSynchronizationBarrier");
pfnDeleteSynchronizationBarrier = WINPR_FUNC_PTR_CAST(fp, fnDeleteSynchronizationBarrier);
}
if (pfnInitializeSynchronizationBarrier && pfnEnterSynchronizationBarrier &&
pfnDeleteSynchronizationBarrier)
{

View File

@ -52,10 +52,10 @@ static WtsApiFunctionTable WtsApi32_WtsApiFunctionTable = { 0 };
#ifdef __MINGW32__
#define WTSAPI32_LOAD_PROC(NAME, TYPE) \
WtsApi32_WtsApiFunctionTable.p##NAME = (TYPE)GetProcAddress(g_WtsApi32Module, "WTS" #NAME);
WtsApi32_WtsApiFunctionTable.p##NAME = GetProcAddressAs(g_WtsApi32Module, "WTS" #NAME, TYPE);
#else
#define WTSAPI32_LOAD_PROC(NAME, TYPE) \
WtsApi32_WtsApiFunctionTable.p##NAME = (##TYPE)GetProcAddress(g_WtsApi32Module, "WTS" #NAME);
WtsApi32_WtsApiFunctionTable.p##NAME = GetProcAddressAs(g_WtsApi32Module, "WTS" #NAME, ##TYPE);
#endif
static BOOL WtsApi32_InitializeWtsApi(void)
@ -700,8 +700,7 @@ static BOOL LoadAndInitialize(char* library)
if (!g_WtsApiModule)
return FALSE;
FARPROC fp = GetProcAddress(g_WtsApiModule, "InitWtsApi");
INIT_WTSAPI_FN pInitWtsApi = WINPR_FUNC_PTR_CAST(fp, INIT_WTSAPI_FN);
INIT_WTSAPI_FN pInitWtsApi = GetProcAddressAs(g_WtsApiModule, "InitWtsApi", INIT_WTSAPI_FN);
if (!pInitWtsApi)
return FALSE;

View File

@ -785,9 +785,9 @@ BOOL Win32_InitializeWinSta(PWtsApiFunctionTable pWtsApi)
return FALSE;
pfnWinStationVirtualOpen =
(fnWinStationVirtualOpen)GetProcAddress(g_WinStaModule, "WinStationVirtualOpen");
GetProcAddressAs(g_WinStaModule, "WinStationVirtualOpen", fnWinStationVirtualOpen);
pfnWinStationVirtualOpenEx =
(fnWinStationVirtualOpenEx)GetProcAddress(g_WinStaModule, "WinStationVirtualOpenEx");
GetProcAddressAs(g_WinStaModule, "WinStationVirtualOpenEx", fnWinStationVirtualOpenEx);
if (!pfnWinStationVirtualOpen | !pfnWinStationVirtualOpenEx)
return FALSE;