Skip to content

Commit

Permalink
On 1.7.x-r1871447 branch:
Browse files Browse the repository at this point in the history
  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
  • Loading branch information
Ivan Zhakov committed Mar 12, 2024
1 parent 97bfd5f commit c39da8c
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions misc/win32/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit c39da8c

Please sign in to comment.