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

View File

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

View File

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

View File

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

View File

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

View File

@ -470,9 +470,8 @@ static BOOL createChildSessionTransport(HANDLE* pFile)
WCHAR pipePath[0x80] = { 0 }; WCHAR pipePath[0x80] = { 0 };
char pipePathA[0x80] = { 0 }; char pipePathA[0x80] = { 0 };
FARPROC fp = GetProcAddress(hModule, "WinStationCreateChildSessionTransport"); WinStationCreateChildSessionTransportFn createChildSessionFn = GetProcAddressAs(
WinStationCreateChildSessionTransportFn createChildSessionFn = hModule, "WinStationCreateChildSessionTransport", WinStationCreateChildSessionTransportFn);
WINPR_FUNC_PTR_CAST(fp, WinStationCreateChildSessionTransportFn);
if (!createChildSessionFn) if (!createChildSessionFn)
{ {
WLog_ERR(TAG, "unable to retrieve WinStationCreateChildSessionTransport function"); 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); WLog_INFO(TAG, "Using SSPI Module: %s", module_name);
FARPROC fp = GetProcAddress(hSSPI, proc_name);
INIT_SECURITY_INTERFACE InitSecurityInterface_ptr = INIT_SECURITY_INTERFACE InitSecurityInterface_ptr =
WINPR_FUNC_PTR_CAST(fp, INIT_SECURITY_INTERFACE); GetProcAddressAs(hSSPI, proc_name, INIT_SECURITY_INTERFACE);
if (!InitSecurityInterface_ptr) if (!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);

View File

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

View File

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

View File

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

View File

@ -160,7 +160,7 @@ WINPR_API const char* winpr_get_build_config(void);
}) })
#else #else
#define WINPR_CAST_CONST_PTR_AWAY(ptr, dstType) (dstType) ptr #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
#endif /* WINPR_H */ #endif /* WINPR_H */

View File

@ -47,13 +47,13 @@ int TestLibraryGetProcAddress(int argc, char* argv[])
return -1; 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__); printf("%s: GetProcAddress failure (FunctionA)\n", __func__);
return -1; 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__); printf("%s: GetProcAddress failure (FunctionB)\n", __func__);
return -1; return -1;

View File

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

View File

@ -1261,8 +1261,8 @@ SECURITY_STATUS NCryptOpenP11StorageProviderEx(NCRYPT_PROV_HANDLE* phProvider,
goto out_load_library; goto out_load_library;
} }
FARPROC fp = GetProcAddress(library, "C_GetFunctionList"); c_get_function_list_t c_get_function_list =
c_get_function_list_t c_get_function_list = WINPR_FUNC_PTR_CAST(fp, c_get_function_list_t); GetProcAddressAs(library, "C_GetFunctionList", c_get_function_list_t);
if (!c_get_function_list) 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"); HMODULE kernel32 = LoadLibraryA("kernel32.dll");
if (kernel32) if (kernel32)
{ pCallbackMayRunLong =
FARPROC fp = GetProcAddress(kernel32, "CallbackMayRunLong"); GetProcAddressAs(kernel32, "CallbackMayRunLong", pCallbackMayRunLong_t);
pCallbackMayRunLong = WINPR_FUNC_PTR_CAST(fp, pCallbackMayRunLong_t);
}
return TRUE; return TRUE;
} }
#endif #endif

View File

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

View File

@ -19,6 +19,7 @@
#include <winpr/config.h> #include <winpr/config.h>
#include <winpr/winpr.h>
#include <winpr/crt.h> #include <winpr/crt.h>
#include <winpr/pool.h> #include <winpr/pool.h>
#include <winpr/library.h> #include <winpr/library.h>
@ -42,11 +43,11 @@ static BOOL CALLBACK init_module(PINIT_ONCE once, PVOID param, PVOID* context)
if (kernel32) if (kernel32)
{ {
pCreateThreadpoolCleanupGroup = pCreateThreadpoolCleanupGroup =
(void*)GetProcAddress(kernel32, "CreateThreadpoolCleanupGroup"); GetProcAddressAs(kernel32, "CreateThreadpoolCleanupGroup", void*);
pCloseThreadpoolCleanupGroupMembers = pCloseThreadpoolCleanupGroupMembers =
(void*)GetProcAddress(kernel32, "CloseThreadpoolCleanupGroupMembers"); GetProcAddressAs(kernel32, "CloseThreadpoolCleanupGroupMembers", void*);
pCloseThreadpoolCleanupGroup = pCloseThreadpoolCleanupGroup =
(void*)GetProcAddress(kernel32, "CloseThreadpoolCleanupGroup"); GetProcAddressAs(kernel32, "CloseThreadpoolCleanupGroup", void*);
} }
return TRUE; 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"); HMODULE kernel32 = LoadLibraryA("kernel32.dll");
if (kernel32) if (kernel32)
{ {
pCreateThreadpool = (void*)GetProcAddress(kernel32, "CreateThreadpool"); pCreateThreadpool = GetProcAddressAs(kernel32, "CreateThreadpool", void*);
pCloseThreadpool = (void*)GetProcAddress(kernel32, "CloseThreadpool"); pCloseThreadpool = GetProcAddressAs(kernel32, "CloseThreadpool", void*);
pSetThreadpoolThreadMinimum = (void*)GetProcAddress(kernel32, "SetThreadpoolThreadMinimum"); pSetThreadpoolThreadMinimum =
pSetThreadpoolThreadMaximum = (void*)GetProcAddress(kernel32, "SetThreadpoolThreadMaximum"); GetProcAddressAs(kernel32, "SetThreadpoolThreadMinimum", void*);
pSetThreadpoolThreadMaximum =
GetProcAddressAs(kernel32, "SetThreadpoolThreadMaximum", void*);
} }
return TRUE; return TRUE;
} }

View File

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

View File

@ -1100,14 +1100,13 @@ 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 \
FARPROC fp = GetProcAddress(hWinSCardLibrary, #_name); \ pWinSCardApiTable->pfn##_name = GetProcAddressAs(hWinSCardLibrary, #_name, fn##_name); \
pWinSCardApiTable->pfn##_name = WINPR_FUNC_PTR_CAST(fp, fn##_name); \ WINPR_PRAGMA_DIAG_POP \
WINPR_PRAGMA_DIAG_POP \
} while (0) } while (0)
BOOL WinSCard_LoadApiTableFunctions(PSCardApiFunctionTable pWinSCardApiTable, BOOL WinSCard_LoadApiTableFunctions(PSCardApiFunctionTable pWinSCardApiTable,

View File

@ -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 = WINPR_FUNC_PTR_CAST(GetProcAddress(module, #_name), fnPCSC##_fname); \ pcsc.pfn##_fname = GetProcAddressAs(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, ...) \

View File

@ -107,10 +107,10 @@ BOOL InitializeSspiModule_Native(void)
if (!g_SspiModule) if (!g_SspiModule)
return FALSE; return FALSE;
pInitSecurityInterfaceW = WINPR_FUNC_PTR_CAST( pInitSecurityInterfaceW =
GetProcAddress(g_SspiModule, "InitSecurityInterfaceW"), INIT_SECURITY_INTERFACE_W); GetProcAddressAs(g_SspiModule, "InitSecurityInterfaceW", INIT_SECURITY_INTERFACE_W);
pInitSecurityInterfaceA = WINPR_FUNC_PTR_CAST( pInitSecurityInterfaceA =
GetProcAddress(g_SspiModule, "InitSecurityInterfaceA"), INIT_SECURITY_INTERFACE_A); GetProcAddressAs(g_SspiModule, "InitSecurityInterfaceA", INIT_SECURITY_INTERFACE_A);
if (pInitSecurityInterfaceW) if (pInitSecurityInterfaceW)
{ {
@ -124,12 +124,11 @@ 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 = WINPR_FUNC_PTR_CAST( g_SspiW->SetContextAttributesW = GetProcAddressAs(g_SspiModule, "SetContextAttributesW",
GetProcAddress(g_SspiModule, "SetContextAttributesW"), SET_CONTEXT_ATTRIBUTES_FN_W); SET_CONTEXT_ATTRIBUTES_FN_W);
g_SspiW->SetCredentialsAttributesW = g_SspiW->SetCredentialsAttributesW = GetProcAddressAs(
WINPR_FUNC_PTR_CAST(GetProcAddress(g_SspiModule, "SetCredentialsAttributesW"), g_SspiModule, "SetCredentialsAttributesW", SET_CREDENTIALS_ATTRIBUTES_FN_W);
SET_CREDENTIALS_ATTRIBUTES_FN_W);
} }
} }
@ -145,12 +144,11 @@ 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 = WINPR_FUNC_PTR_CAST( g_SspiA->SetContextAttributesA = GetProcAddressAs(g_SspiModule, "SetContextAttributesA",
GetProcAddress(g_SspiModule, "SetContextAttributesA"), SET_CONTEXT_ATTRIBUTES_FN_W); SET_CONTEXT_ATTRIBUTES_FN_W);
g_SspiA->SetCredentialsAttributesA = g_SspiA->SetCredentialsAttributesA = GetProcAddressAs(
WINPR_FUNC_PTR_CAST(GetProcAddress(g_SspiModule, "SetCredentialsAttributesA"), g_SspiModule, "SetCredentialsAttributesA", SET_CREDENTIALS_ATTRIBUTES_FN_W);
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) if (!g_Kernel32)
return TRUE; return TRUE;
pfnInitializeSynchronizationBarrier = (fnInitializeSynchronizationBarrier)GetProcAddress( pfnInitializeSynchronizationBarrier = GetProcAddressAs(
g_Kernel32, "InitializeSynchronizationBarrier"); 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 && if (pfnInitializeSynchronizationBarrier && pfnEnterSynchronizationBarrier &&
pfnDeleteSynchronizationBarrier) pfnDeleteSynchronizationBarrier)
{ {

View File

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

View File

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