From c39da8c2cd268edd1a6b151483411432ff807ace Mon Sep 17 00:00:00 2001 From: Ivan Zhakov Date: Tue, 12 Mar 2024 13:17:49 +0000 Subject: [PATCH] On 1.7.x-r1871447 branch: Merge r1859404 from trunk. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x-r1871447@1916254 13f79535-47bb-0310-9956-ffa450edef68 --- misc/win32/misc.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/misc/win32/misc.c b/misc/win32/misc.c index bfb7efae57d..971ae1077ad 100644 --- a/misc/win32/misc.c +++ b/misc/win32/misc.c @@ -161,32 +161,40 @@ apr_status_t apr_get_oslevel(apr_oslevel_e *level) * missing from one or more releases of the Win32 API */ -static const char* const lateDllName[DLL_defined] = { - "kernel32", "advapi32", "mswsock", "ws2_32", "shell32", "ntdll.dll", - "Iphplapi" }; -static HMODULE lateDllHandle[DLL_defined] = { - NULL, NULL, NULL, NULL, NULL, NULL, - NULL }; +typedef struct win32_late_dll_t { + const char *dll_name; + HMODULE dll_handle; +} win32_late_dll_t; + +static win32_late_dll_t late_dll[DLL_defined] = { + {"kernel32", NULL}, + {"advapi32", NULL}, + {"mswsock", NULL}, + {"ws2_32", NULL}, + {"shell32", NULL}, + {"ntdll.dll", NULL}, + {"Iphplapi", NULL} +}; FARPROC apr_load_dll_func(apr_dlltoken_e fnLib, char* fnName, int ordinal) { - if (!lateDllHandle[fnLib]) { - lateDllHandle[fnLib] = LoadLibraryA(lateDllName[fnLib]); - if (!lateDllHandle[fnLib]) + if (!late_dll[fnLib].dll_handle) { + late_dll[fnLib].dll_handle = LoadLibraryA(late_dll[fnLib].dll_name); + if (!late_dll[fnLib].dll_handle) return NULL; } #if defined(_WIN32_WCE) if (ordinal) - return GetProcAddressA(lateDllHandle[fnLib], (const char *) - (apr_ssize_t)ordinal); + return GetProcAddressA(late_dll[fnLib].dll_handle, + (const char *) (apr_ssize_t)ordinal); else - return GetProcAddressA(lateDllHandle[fnLib], fnName); + return GetProcAddressA(late_dll[fnLib].dll_handle, fnName); #else if (ordinal) - return GetProcAddress(lateDllHandle[fnLib], (const char *) - (apr_ssize_t)ordinal); + return GetProcAddress(late_dll[fnLib].dll_handle, + (const char *) (apr_ssize_t)ordinal); else - return GetProcAddress(lateDllHandle[fnLib], fnName); + return GetProcAddress(late_dll[fnLib].dll_handle, fnName); #endif }