19 #ifndef COMPAT_W32DLFCN_H
20 #define COMPAT_W32DLFCN_H
24 #if _WIN32_WINNT < 0x0602
34 static inline HMODULE win32_dlopen(
const char *
name)
36 #if _WIN32_WINNT < 0x0602
38 if (!GetProcAddress(GetModuleHandleW(
L"kernel32.dll"),
"SetDefaultDllDirectories")) {
40 wchar_t *path =
NULL, *name_w =
NULL;
42 if (utf8towchar(name, &name_w))
46 pathlen = GetModuleFileNameW(
NULL, path, MAX_PATH);
47 pathlen = wcsrchr(path,
'\\') - path;
48 if (pathlen == 0 || pathlen + wcslen(name_w) + 2 > MAX_PATH)
51 wcscpy(path + pathlen + 1, name_w);
52 module = LoadLibraryExW(path,
NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
55 pathlen = GetSystemDirectoryW(path, MAX_PATH);
56 if (pathlen == 0 || pathlen + wcslen(name_w) + 2 > MAX_PATH)
59 wcscpy(path + pathlen + 1, name_w);
60 module = LoadLibraryExW(path,
NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
68 #ifndef LOAD_LIBRARY_SEARCH_APPLICATION_DIR
69 # define LOAD_LIBRARY_SEARCH_APPLICATION_DIR 0x00000200
71 #ifndef LOAD_LIBRARY_SEARCH_SYSTEM32
72 # define LOAD_LIBRARY_SEARCH_SYSTEM32 0x00000800
74 return LoadLibraryExA(name,
NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32);
76 #define dlopen(name, flags) win32_dlopen(name)
77 #define dlclose FreeLibrary
78 #define dlsym GetProcAddress
static void * av_mallocz_array(size_t nmemb, size_t size)