static int load_xrandr(void) { int r = 0; if (wine_dlopen(SONAME_LIBX11, RTLD_NOW|RTLD_GLOBAL, NULL, 0) && wine_dlopen(SONAME_LIBXEXT, RTLD_NOW|RTLD_GLOBAL, NULL, 0) && wine_dlopen(SONAME_LIBXRENDER, RTLD_NOW|RTLD_GLOBAL, NULL, 0) && (xrandr_handle = wine_dlopen(SONAME_LIBXRANDR, RTLD_NOW, NULL, 0))) { #define LOAD_FUNCPTR(f) \ if((p##f = wine_dlsym(xrandr_handle, #f, NULL, 0)) == NULL) \ goto sym_not_found; LOAD_FUNCPTR(XRRConfigCurrentConfiguration) LOAD_FUNCPTR(XRRConfigCurrentRate) LOAD_FUNCPTR(XRRFreeScreenConfigInfo) LOAD_FUNCPTR(XRRGetScreenInfo) LOAD_FUNCPTR(XRRQueryExtension) LOAD_FUNCPTR(XRRQueryVersion) LOAD_FUNCPTR(XRRRates) LOAD_FUNCPTR(XRRSetScreenConfig) LOAD_FUNCPTR(XRRSetScreenConfigAndRate) LOAD_FUNCPTR(XRRSizes) #undef LOAD_FUNCPTR r = 1; /* success */ sym_not_found: if (!r) TRACE("Unable to load function ptrs from XRandR library\n"); } return r; }
static BOOL load_hal_functions(void) { void *hal_handle; char error[128]; /* Load libhal with RTLD_GLOBAL so that the dbus symbols are available. * We can't load libdbus directly since libhal may have been built against a * different version but with the same soname. Binary compatibility is for wimps. */ if (!(hal_handle = wine_dlopen(SONAME_LIBHAL, RTLD_NOW|RTLD_GLOBAL, error, sizeof(error)))) goto failed; #define DO_FUNC(f) if (!(p_##f = wine_dlsym( RTLD_DEFAULT, #f, error, sizeof(error) ))) goto failed DBUS_FUNCS; #undef DO_FUNC #define DO_FUNC(f) if (!(p_##f = wine_dlsym( hal_handle, #f, error, sizeof(error) ))) goto failed HAL_FUNCS; #undef DO_FUNC udisks_timeout = 3000; /* don't try for too long if we can fall back to HAL */ return TRUE; failed: WARN( "failed to load HAL support: %s\n", error ); return FALSE; }
static void init_libxslt(void) { #ifdef SONAME_LIBXSLT void (*pxsltInit)(void); /* Missing in libxslt <= 1.1.14 */ libxslt_handle = wine_dlopen(SONAME_LIBXSLT, RTLD_NOW, NULL, 0); if (!libxslt_handle) return; #define LOAD_FUNCPTR(f, needed) \ if ((p##f = wine_dlsym(libxslt_handle, #f, NULL, 0)) == NULL) \ if (needed) { WARN("Can't find symbol %s\n", #f); goto sym_not_found; } LOAD_FUNCPTR(xsltInit, 0); LOAD_FUNCPTR(xsltApplyStylesheet, 1); LOAD_FUNCPTR(xsltApplyStylesheetUser, 1); LOAD_FUNCPTR(xsltCleanupGlobals, 1); LOAD_FUNCPTR(xsltFreeStylesheet, 1); LOAD_FUNCPTR(xsltFreeTransformContext, 1); LOAD_FUNCPTR(xsltNewTransformContext, 1); LOAD_FUNCPTR(xsltParseStylesheetDoc, 1); LOAD_FUNCPTR(xsltQuoteUserParams, 1); #undef LOAD_FUNCPTR if (pxsltInit) pxsltInit(); return; sym_not_found: wine_dlclose(libxslt_handle, NULL, 0); libxslt_handle = NULL; #endif }
static void *load_libjpeg(void) { if((libjpeg_handle = wine_dlopen(SONAME_LIBJPEG, RTLD_NOW, NULL, 0)) != NULL) { #define LOAD_FUNCPTR(f) \ if((p##f = wine_dlsym(libjpeg_handle, #f, NULL, 0)) == NULL) { \ libjpeg_handle = NULL; \ return NULL; \ } LOAD_FUNCPTR(jpeg_CreateCompress); LOAD_FUNCPTR(jpeg_CreateDecompress); LOAD_FUNCPTR(jpeg_destroy_compress); LOAD_FUNCPTR(jpeg_destroy_decompress); LOAD_FUNCPTR(jpeg_finish_compress); LOAD_FUNCPTR(jpeg_read_header); LOAD_FUNCPTR(jpeg_read_scanlines); LOAD_FUNCPTR(jpeg_resync_to_restart); LOAD_FUNCPTR(jpeg_set_defaults); LOAD_FUNCPTR(jpeg_start_compress); LOAD_FUNCPTR(jpeg_start_decompress); LOAD_FUNCPTR(jpeg_std_error); LOAD_FUNCPTR(jpeg_write_scanlines); #undef LOAD_FUNCPTR } return libjpeg_handle; }
static void *load_libglu(void) { static int already_loaded; void *handle; if (already_loaded) return libglu_handle; already_loaded = 1; TRACE("Trying to load GLU library: %s\n", SONAME_LIBGLU); handle = wine_dlopen(SONAME_LIBGLU, RTLD_NOW, NULL, 0); if (!handle) { WARN("Failed to load %s\n", SONAME_LIBGLU); return NULL; } #define LOAD_FUNCPTR(f) if((p##f = (void*)wine_dlsym(handle, #f, NULL, 0)) == NULL) goto sym_not_found; LOAD_FUNCPTR(gluNewTess) LOAD_FUNCPTR(gluDeleteTess) LOAD_FUNCPTR(gluTessBeginContour) LOAD_FUNCPTR(gluTessBeginPolygon) LOAD_FUNCPTR(gluTessCallback) LOAD_FUNCPTR(gluTessEndContour) LOAD_FUNCPTR(gluTessEndPolygon) LOAD_FUNCPTR(gluTessVertex) #undef LOAD_FUNCPTR libglu_handle = handle; return handle; sym_not_found: WARN("Unable to load function ptrs from libGLU\n"); /* Close the library as we won't use it */ wine_dlclose(handle, NULL, 0); return NULL; }
static int load_xrandr(void) { int r = 0; if (wine_dlopen(SONAME_LIBXRENDER, RTLD_NOW|RTLD_GLOBAL, NULL, 0) && (xrandr_handle = wine_dlopen(SONAME_LIBXRANDR, RTLD_NOW, NULL, 0))) { #define LOAD_FUNCPTR(f) \ if((p##f = wine_dlsym(xrandr_handle, #f, NULL, 0)) == NULL) \ goto sym_not_found; LOAD_FUNCPTR(XRRConfigCurrentConfiguration) LOAD_FUNCPTR(XRRConfigCurrentRate) LOAD_FUNCPTR(XRRFreeScreenConfigInfo) LOAD_FUNCPTR(XRRGetScreenInfo) LOAD_FUNCPTR(XRRQueryExtension) LOAD_FUNCPTR(XRRQueryVersion) LOAD_FUNCPTR(XRRRates) LOAD_FUNCPTR(XRRSetScreenConfig) LOAD_FUNCPTR(XRRSetScreenConfigAndRate) LOAD_FUNCPTR(XRRSizes) r = 1; #ifdef HAVE_XRRGETSCREENRESOURCES LOAD_FUNCPTR(XRRFreeCrtcInfo) LOAD_FUNCPTR(XRRFreeOutputInfo) LOAD_FUNCPTR(XRRFreeScreenResources) LOAD_FUNCPTR(XRRGetCrtcInfo) LOAD_FUNCPTR(XRRGetOutputInfo) LOAD_FUNCPTR(XRRGetScreenResources) LOAD_FUNCPTR(XRRSetCrtcConfig) r = 2; #endif #undef LOAD_FUNCPTR sym_not_found: if (!r) TRACE("Unable to load function ptrs from XRandR library\n"); } return r; }
static void *load_libpng(void) { if((libpng_handle = wine_dlopen(SONAME_LIBPNG, RTLD_NOW, NULL, 0)) != NULL) { #define LOAD_FUNCPTR(f) \ if((p##f = wine_dlsym(libpng_handle, #f, NULL, 0)) == NULL) { \ libpng_handle = NULL; \ return NULL; \ } LOAD_FUNCPTR(png_create_read_struct); LOAD_FUNCPTR(png_create_info_struct); LOAD_FUNCPTR(png_create_write_struct); LOAD_FUNCPTR(png_destroy_read_struct); LOAD_FUNCPTR(png_destroy_write_struct); LOAD_FUNCPTR(png_error); LOAD_FUNCPTR(png_get_bit_depth); LOAD_FUNCPTR(png_get_color_type); LOAD_FUNCPTR(png_get_error_ptr); LOAD_FUNCPTR(png_get_iCCP); LOAD_FUNCPTR(png_get_image_height); LOAD_FUNCPTR(png_get_image_width); LOAD_FUNCPTR(png_get_io_ptr); LOAD_FUNCPTR(png_get_pHYs); LOAD_FUNCPTR(png_get_PLTE); LOAD_FUNCPTR(png_get_tRNS); LOAD_FUNCPTR(png_set_bgr); LOAD_FUNCPTR(png_set_crc_action); LOAD_FUNCPTR(png_set_error_fn); #ifdef HAVE_PNG_SET_EXPAND_GRAY_1_2_4_TO_8 LOAD_FUNCPTR(png_set_expand_gray_1_2_4_to_8); #else LOAD_FUNCPTR(png_set_gray_1_2_4_to_8); #endif LOAD_FUNCPTR(png_set_filler); LOAD_FUNCPTR(png_set_gray_to_rgb); LOAD_FUNCPTR(png_set_interlace_handling); LOAD_FUNCPTR(png_set_IHDR); LOAD_FUNCPTR(png_set_pHYs); LOAD_FUNCPTR(png_set_read_fn); LOAD_FUNCPTR(png_set_strip_16); LOAD_FUNCPTR(png_set_tRNS_to_alpha); LOAD_FUNCPTR(png_set_write_fn); LOAD_FUNCPTR(png_read_end); LOAD_FUNCPTR(png_read_image); LOAD_FUNCPTR(png_read_info); LOAD_FUNCPTR(png_write_end); LOAD_FUNCPTR(png_write_info); LOAD_FUNCPTR(png_write_rows); #undef LOAD_FUNCPTR } return libpng_handle; }
static BOOL load_functions(void) { void *dbus_handle, *hal_handle; char error[128]; if (!(dbus_handle = wine_dlopen(SONAME_LIBDBUS_1, RTLD_NOW, error, sizeof(error)))) goto failed; if (!(hal_handle = wine_dlopen(SONAME_LIBHAL, RTLD_NOW, error, sizeof(error)))) goto failed; #define DO_FUNC(f) if (!(p_##f = wine_dlsym( dbus_handle, #f, error, sizeof(error) ))) goto failed DBUS_FUNCS; #undef DO_FUNC #define DO_FUNC(f) if (!(p_##f = wine_dlsym( hal_handle, #f, error, sizeof(error) ))) goto failed HAL_FUNCS; #undef DO_FUNC return TRUE; failed: WINE_WARN( "failed to load HAL support: %s\n", error ); return FALSE; }
static void load_xinerama(void) { void *handle; if (!(handle = wine_dlopen(SONAME_LIBXINERAMA, RTLD_NOW, NULL, 0))) { WARN( "failed to open %s\n", SONAME_LIBXINERAMA ); return; } pXineramaQueryExtension = wine_dlsym( handle, "XineramaQueryExtension", NULL, 0 ); if (!pXineramaQueryExtension) WARN( "XineramaQueryScreens not found\n" ); pXineramaQueryScreens = wine_dlsym( handle, "XineramaQueryScreens", NULL, 0 ); if (!pXineramaQueryScreens) WARN( "XineramaQueryScreens not found\n" ); }
static int load_functions(void) { char soname[MAX_PATH] = FALLBACK_LIBCTAPI, buffer[MAX_PATH]; LONG result; HKEY key_handle; if (pCT_init) /* loaded already */ return 0; /* Try to get name of low level library from registry */ /* @@ Wine registry key: HKCU\Software\Wine\ctapi32 */ result = RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\Wine\\ctapi32", 0, KEY_READ, &key_handle); if (result == ERROR_SUCCESS) { DWORD type, size; WCHAR buffer_w[MAX_PATH]; size = sizeof(buffer_w) - sizeof(WCHAR); /* Leave space for null termination */ result = RegQueryValueExW(key_handle, value_name, NULL, &type, (LPBYTE)buffer_w, &size); if ((result == ERROR_SUCCESS) && (type == REG_SZ)) { int len; /* Null termination */ buffer_w[size / sizeof(WCHAR)] = '\0'; len = WideCharToMultiByte(CP_UNIXCP, 0, buffer_w, -1, buffer, sizeof(buffer), NULL, NULL); if (len) memcpy(soname, buffer, len); } RegCloseKey(key_handle); } TRACE("Loading library '%s'\n", soname); ctapi_handle = wine_dlopen(soname, RTLD_NOW, NULL, 0); if (ctapi_handle) { TRACE("Successfully loaded '%s'\n", soname); } else { MESSAGE("Wine cannot find any usable hardware library, ctapi32.dll not working.\n"); MESSAGE("Please create the key \"HKEY_CURRENT_USER\\Software\\Wine\\ctapi32\" in your registry\n"); MESSAGE("and set the value \"library\" to your library name (e.g. \"libctapi-cyberjack.so.1\" or \"/usr/lib/readers/libctapi.so\").\n"); return 1; } #define LOAD_FUNCPTR(f) if((p##f = wine_dlsym(ctapi_handle, #f, NULL, 0)) == NULL){WARN("Can't find symbol %s\n", #f); return 1;} LOAD_FUNCPTR(CT_init); LOAD_FUNCPTR(CT_data); LOAD_FUNCPTR(CT_close); #undef LOAD_FUNCPTR return 0; }
/* open a library for a given dll, searching in the dll path * 'name' must be the Windows dll name (e.g. "kernel32.dll") */ static void *dlopen_dll( const char *name, char *error, int errorsize, int test_only, int *exists ) { struct dll_path_context context; char *path; void *ret = NULL; *exists = 0; for (path = first_dll_path( name, 0, &context ); path; path = next_dll_path( &context )) { if (!test_only && (ret = wine_dlopen( path, RTLD_NOW, error, errorsize ))) break; if ((*exists = file_exists( path ))) break; /* exists but cannot be loaded, return the error */ } free_dll_path( &context ); return ret; }
static BOOL gnutls_initialize(void) { int ret; if (!(libgnutls_handle = wine_dlopen( SONAME_LIBGNUTLS, RTLD_NOW, NULL, 0 ))) { ERR_(winediag)( "failed to load libgnutls, no support for crypto hashes\n" ); return FALSE; } #define LOAD_FUNCPTR(f) \ if (!(p##f = wine_dlsym( libgnutls_handle, #f, NULL, 0 ))) \ { \ ERR( "failed to load %s\n", #f ); \ goto fail; \ } LOAD_FUNCPTR(gnutls_global_deinit) LOAD_FUNCPTR(gnutls_global_init) LOAD_FUNCPTR(gnutls_global_set_log_function) LOAD_FUNCPTR(gnutls_global_set_log_level) LOAD_FUNCPTR(gnutls_hash); LOAD_FUNCPTR(gnutls_hash_deinit); LOAD_FUNCPTR(gnutls_hash_init); LOAD_FUNCPTR(gnutls_perror) #undef LOAD_FUNCPTR if ((ret = pgnutls_global_init()) != GNUTLS_E_SUCCESS) { pgnutls_perror( ret ); goto fail; } if (TRACE_ON( bcrypt )) { pgnutls_global_set_log_level( 4 ); pgnutls_global_set_log_function( gnutls_log ); } return TRUE; fail: wine_dlclose( libgnutls_handle, NULL, 0 ); libgnutls_handle = NULL; return FALSE; }
static BOOL init_opengl(void) { static BOOL init_done = FALSE; static void *osmesa_handle; char buffer[200]; unsigned int i; if (init_done) return (osmesa_handle != NULL); init_done = TRUE; osmesa_handle = wine_dlopen( SONAME_LIBOSMESA, RTLD_NOW, buffer, sizeof(buffer) ); if (osmesa_handle == NULL) { ERR( "Failed to load OSMesa: %s\n", buffer ); return FALSE; } #define LOAD_FUNCPTR(f) do if (!(p##f = wine_dlsym( osmesa_handle, #f, buffer, sizeof(buffer) ))) \ { \ ERR( "%s not found in %s (%s), disabling.\n", #f, SONAME_LIBOSMESA, buffer ); \ goto failed; \ } while(0) LOAD_FUNCPTR(OSMesaCreateContextExt); LOAD_FUNCPTR(OSMesaDestroyContext); LOAD_FUNCPTR(OSMesaGetProcAddress); LOAD_FUNCPTR(OSMesaMakeCurrent); LOAD_FUNCPTR(OSMesaPixelStore); #undef LOAD_FUNCPTR for (i = 0; i < sizeof(opengl_func_names)/sizeof(opengl_func_names[0]); i++) { if (!(((void **)&opengl_funcs.gl)[i] = pOSMesaGetProcAddress( opengl_func_names[i] ))) { ERR( "%s not found in %s, disabling.\n", opengl_func_names[i], SONAME_LIBOSMESA ); goto failed; } } return TRUE; failed: wine_dlclose( osmesa_handle, NULL, 0 ); osmesa_handle = NULL; return FALSE; }
/************************************************************************** * JACK_drvLoad [internal] */ static LRESULT JACK_drvLoad(void) { TRACE("()\n"); /* dynamically load the jack library if not already loaded */ jackhandle = wine_dlopen(SONAME_LIBJACK, RTLD_NOW, NULL, 0); TRACE("SONAME_LIBJACK == %s\n", SONAME_LIBJACK); TRACE("jackhandle == %p\n", jackhandle); if(!jackhandle) { FIXME("error loading the jack library %s, please install this library to use jack\n", SONAME_LIBJACK); return 0; } return 1; }
static void video_init(void) { #ifdef SONAME_LIBV4L1 static void *video_lib; if (video_lib) return; video_lib = wine_dlopen(SONAME_LIBV4L1, RTLD_NOW, NULL, 0); if (!video_lib) return; video_open = wine_dlsym(video_lib, "v4l1_open", NULL, 0); video_close = wine_dlsym(video_lib, "v4l1_close", NULL, 0); video_ioctl = wine_dlsym(video_lib, "v4l1_ioctl", NULL, 0); video_read = wine_dlsym(video_lib, "v4l1_read", NULL, 0); video_mmap = wine_dlsym(video_lib, "v4l1_mmap", NULL, 0); video_munmap = wine_dlsym(video_lib, "v4l1_munmap", NULL, 0); #endif }
/*********************************************************************** * GSM_drvLoad */ static LRESULT GSM_drvLoad(void) { char error[128]; libgsm_handle = wine_dlopen(SONAME_LIBGSM, RTLD_NOW, error, sizeof(error)); if (libgsm_handle) { LOAD_FUNCPTR(gsm_create); LOAD_FUNCPTR(gsm_destroy); LOAD_FUNCPTR(gsm_option); LOAD_FUNCPTR(gsm_encode); LOAD_FUNCPTR(gsm_decode); return 1; } else { ERR("Couldn't load " SONAME_LIBGSM ": %s\n", error); return 0; } }
/*********************************************************************** * X11DRV_Xcursor_Init * * Load the Xcursor library for use. */ void X11DRV_Xcursor_Init(void) { #ifdef SONAME_LIBXCURSOR xcursor_handle = wine_dlopen(SONAME_LIBXCURSOR, RTLD_NOW, NULL, 0); if (!xcursor_handle) /* wine_dlopen failed. */ { WARN("Xcursor failed to load. Using fallback code.\n"); return; } #define LOAD_FUNCPTR(f) \ p##f = wine_dlsym(xcursor_handle, #f, NULL, 0) LOAD_FUNCPTR(XcursorImageCreate); LOAD_FUNCPTR(XcursorImageDestroy); LOAD_FUNCPTR(XcursorImageLoadCursor); LOAD_FUNCPTR(XcursorImagesCreate); LOAD_FUNCPTR(XcursorImagesDestroy); LOAD_FUNCPTR(XcursorImagesLoadCursor); LOAD_FUNCPTR(XcursorLibraryLoadCursor); #undef LOAD_FUNCPTR #endif /* SONAME_LIBXCURSOR */ }
static void *load_libpng(void) { if ((libpng_handle = wine_dlopen(SONAME_LIBPNG, RTLD_NOW, NULL, 0)) != NULL) { #define LOAD_FUNCPTR(f) \ if((p##f = wine_dlsym(libpng_handle, #f, NULL, 0)) == NULL) { \ libpng_handle = NULL; \ return NULL; \ } LOAD_FUNCPTR(png_create_info_struct); LOAD_FUNCPTR(png_create_write_struct); LOAD_FUNCPTR(png_destroy_write_struct); LOAD_FUNCPTR(png_init_io); LOAD_FUNCPTR(png_set_bgr); LOAD_FUNCPTR(png_set_IHDR); LOAD_FUNCPTR(png_set_text); LOAD_FUNCPTR(png_write_end); LOAD_FUNCPTR(png_write_info); LOAD_FUNCPTR(png_write_row); #undef LOAD_FUNCPTR } return libpng_handle; }
/*********************************************************************** * wine_init * * Main Wine initialisation. */ void wine_init( int argc, char *argv[], char *error, int error_size ) { struct dll_path_context context; char *path; void *ntdll = NULL; void (*init_func)(void); /* force a few limits that are set too low on some platforms */ #ifdef RLIMIT_NOFILE set_max_limit( RLIMIT_NOFILE ); #endif #ifdef RLIMIT_AS set_max_limit( RLIMIT_AS ); #endif wine_init_argv0_path( argv[0] ); build_dll_path(); __wine_main_argc = argc; __wine_main_argv = argv; __wine_main_environ = environ; mmap_init(); for (path = first_dll_path( "ntdll.dll", 0, &context ); path; path = next_dll_path( &context )) { if ((ntdll = wine_dlopen( path, RTLD_NOW, error, error_size ))) { /* if we didn't use the default dll dir, remove it from the search path */ if (default_dlldir[0] && context.index < nb_dll_paths + 2) nb_dll_paths--; break; } } free_dll_path( &context ); if (!ntdll) return; if (!(init_func = wine_dlsym( ntdll, "__wine_process_init", error, error_size ))) return; init_func(); }
BOOL netconn_init( netconn_t *conn, BOOL secure ) { #if defined(SONAME_LIBSSL) && defined(SONAME_LIBCRYPTO) int i; #endif conn->socket = -1; if (!secure) return TRUE; #if defined(SONAME_LIBSSL) && defined(SONAME_LIBCRYPTO) EnterCriticalSection( &init_ssl_cs ); if (libssl_handle) { LeaveCriticalSection( &init_ssl_cs ); return TRUE; } if (!(libssl_handle = wine_dlopen( SONAME_LIBSSL, RTLD_NOW, NULL, 0 ))) { ERR("Trying to use SSL but couldn't load %s. Expect trouble.\n", SONAME_LIBSSL); set_last_error( ERROR_WINHTTP_SECURE_CHANNEL_ERROR ); LeaveCriticalSection( &init_ssl_cs ); return FALSE; } if (!(libcrypto_handle = wine_dlopen( SONAME_LIBCRYPTO, RTLD_NOW, NULL, 0 ))) { ERR("Trying to use SSL but couldn't load %s. Expect trouble.\n", SONAME_LIBCRYPTO); set_last_error( ERROR_WINHTTP_SECURE_CHANNEL_ERROR ); LeaveCriticalSection( &init_ssl_cs ); return FALSE; } #define LOAD_FUNCPTR(x) \ if (!(p##x = wine_dlsym( libssl_handle, #x, NULL, 0 ))) \ { \ ERR("Failed to load symbol %s\n", #x); \ set_last_error( ERROR_WINHTTP_SECURE_CHANNEL_ERROR ); \ LeaveCriticalSection( &init_ssl_cs ); \ return FALSE; \ } LOAD_FUNCPTR( SSL_library_init ); LOAD_FUNCPTR( SSL_load_error_strings ); LOAD_FUNCPTR( SSLv23_method ); LOAD_FUNCPTR( SSL_CTX_free ); LOAD_FUNCPTR( SSL_CTX_new ); LOAD_FUNCPTR( SSL_new ); LOAD_FUNCPTR( SSL_free ); LOAD_FUNCPTR( SSL_set_fd ); LOAD_FUNCPTR( SSL_connect ); LOAD_FUNCPTR( SSL_shutdown ); LOAD_FUNCPTR( SSL_write ); LOAD_FUNCPTR( SSL_read ); LOAD_FUNCPTR( SSL_get_error ); LOAD_FUNCPTR( SSL_get_ex_new_index ); LOAD_FUNCPTR( SSL_get_ex_data ); LOAD_FUNCPTR( SSL_set_ex_data ); LOAD_FUNCPTR( SSL_get_ex_data_X509_STORE_CTX_idx ); LOAD_FUNCPTR( SSL_get_peer_certificate ); LOAD_FUNCPTR( SSL_CTX_set_default_verify_paths ); LOAD_FUNCPTR( SSL_CTX_set_verify ); LOAD_FUNCPTR( SSL_get_current_cipher ); LOAD_FUNCPTR( SSL_CIPHER_get_bits ); #undef LOAD_FUNCPTR #define LOAD_FUNCPTR(x) \ if (!(p##x = wine_dlsym( libcrypto_handle, #x, NULL, 0 ))) \ { \ ERR("Failed to load symbol %s\n", #x); \ set_last_error( ERROR_WINHTTP_SECURE_CHANNEL_ERROR ); \ LeaveCriticalSection( &init_ssl_cs ); \ return FALSE; \ } LOAD_FUNCPTR( CRYPTO_num_locks ); LOAD_FUNCPTR( CRYPTO_set_id_callback ); LOAD_FUNCPTR( CRYPTO_set_locking_callback ); LOAD_FUNCPTR( ERR_free_strings ); LOAD_FUNCPTR( ERR_get_error ); LOAD_FUNCPTR( ERR_error_string ); LOAD_FUNCPTR( X509_STORE_CTX_get_ex_data ); LOAD_FUNCPTR( i2d_X509 ); LOAD_FUNCPTR( sk_value ); LOAD_FUNCPTR( sk_num ); #undef LOAD_FUNCPTR pSSL_library_init(); pSSL_load_error_strings(); method = pSSLv23_method(); ctx = pSSL_CTX_new( method ); if (!pSSL_CTX_set_default_verify_paths( ctx )) { ERR("SSL_CTX_set_default_verify_paths failed: %s\n", pERR_error_string( pERR_get_error(), 0 )); set_last_error( ERROR_OUTOFMEMORY ); LeaveCriticalSection( &init_ssl_cs ); return FALSE; } hostname_idx = pSSL_get_ex_new_index( 0, (void *)"hostname index", NULL, NULL, NULL ); if (hostname_idx == -1) { ERR("SSL_get_ex_new_index failed: %s\n", pERR_error_string( pERR_get_error(), 0 )); set_last_error( ERROR_OUTOFMEMORY ); LeaveCriticalSection( &init_ssl_cs ); return FALSE; } error_idx = pSSL_get_ex_new_index( 0, (void *)"error index", NULL, NULL, NULL ); if (error_idx == -1) { ERR("SSL_get_ex_new_index failed: %s\n", pERR_error_string( pERR_get_error(), 0 )); set_last_error( ERROR_OUTOFMEMORY ); LeaveCriticalSection( &init_ssl_cs ); return FALSE; } conn_idx = pSSL_get_ex_new_index( 0, (void *)"netconn index", NULL, NULL, NULL ); if (conn_idx == -1) { ERR("SSL_get_ex_new_index failed: %s\n", pERR_error_string( pERR_get_error(), 0 )); set_last_error( ERROR_OUTOFMEMORY ); LeaveCriticalSection( &init_ssl_cs ); return FALSE; } pSSL_CTX_set_verify( ctx, SSL_VERIFY_PEER, netconn_secure_verify ); pCRYPTO_set_id_callback(ssl_thread_id); num_ssl_locks = pCRYPTO_num_locks(); ssl_locks = HeapAlloc(GetProcessHeap(), 0, num_ssl_locks * sizeof(CRITICAL_SECTION)); if (!ssl_locks) { set_last_error( ERROR_OUTOFMEMORY ); LeaveCriticalSection( &init_ssl_cs ); return FALSE; } for (i = 0; i < num_ssl_locks; i++) InitializeCriticalSection( &ssl_locks[i] ); pCRYPTO_set_locking_callback(ssl_lock_callback); LeaveCriticalSection( &init_ssl_cs ); #else WARN("SSL support not compiled in.\n"); set_last_error( ERROR_WINHTTP_SECURE_CHANNEL_ERROR ); return FALSE; #endif return TRUE; }
BOOL netconn_init( netconn_t *conn, BOOL secure ) { conn->socket = -1; if (!secure) return TRUE; #if defined(SONAME_LIBSSL) && defined(SONAME_LIBCRYPTO) if (libssl_handle) return TRUE; if (!(libssl_handle = wine_dlopen( SONAME_LIBSSL, RTLD_NOW, NULL, 0 ))) { ERR("Trying to use SSL but couldn't load %s. Expect trouble.\n", SONAME_LIBSSL); set_last_error( ERROR_WINHTTP_SECURE_CHANNEL_ERROR ); return FALSE; } if (!(libcrypto_handle = wine_dlopen( SONAME_LIBCRYPTO, RTLD_NOW, NULL, 0 ))) { ERR("Trying to use SSL but couldn't load %s. Expect trouble.\n", SONAME_LIBCRYPTO); set_last_error( ERROR_WINHTTP_SECURE_CHANNEL_ERROR ); return FALSE; } #define LOAD_FUNCPTR(x) \ if (!(p##x = wine_dlsym( libssl_handle, #x, NULL, 0 ))) \ { \ ERR("Failed to load symbol %s\n", #x); \ set_last_error( ERROR_WINHTTP_SECURE_CHANNEL_ERROR ); \ return FALSE; \ } LOAD_FUNCPTR( SSL_library_init ); LOAD_FUNCPTR( SSL_load_error_strings ); LOAD_FUNCPTR( SSLv23_method ); LOAD_FUNCPTR( SSL_CTX_new ); LOAD_FUNCPTR( SSL_new ); LOAD_FUNCPTR( SSL_free ); LOAD_FUNCPTR( SSL_set_fd ); LOAD_FUNCPTR( SSL_connect ); LOAD_FUNCPTR( SSL_shutdown ); LOAD_FUNCPTR( SSL_write ); LOAD_FUNCPTR( SSL_read ); LOAD_FUNCPTR( SSL_get_verify_result ); LOAD_FUNCPTR( SSL_get_peer_certificate ); LOAD_FUNCPTR( SSL_CTX_get_timeout ); LOAD_FUNCPTR( SSL_CTX_set_timeout ); LOAD_FUNCPTR( SSL_CTX_set_default_verify_paths ); LOAD_FUNCPTR( i2d_X509 ); #undef LOAD_FUNCPTR #define LOAD_FUNCPTR(x) \ if (!(p##x = wine_dlsym( libcrypto_handle, #x, NULL, 0 ))) \ { \ ERR("Failed to load symbol %s\n", #x); \ set_last_error( ERROR_WINHTTP_SECURE_CHANNEL_ERROR ); \ return FALSE; \ } LOAD_FUNCPTR( BIO_new_fp ); LOAD_FUNCPTR( ERR_get_error ); LOAD_FUNCPTR( ERR_error_string ); #undef LOAD_FUNCPTR pSSL_library_init(); pSSL_load_error_strings(); pBIO_new_fp( stderr, BIO_NOCLOSE ); method = pSSLv23_method(); #else WARN("SSL support not compiled in.\n"); set_last_error( ERROR_WINHTTP_SECURE_CHANNEL_ERROR ); return FALSE; #endif return TRUE; }
BOOL NETCON_init(WININET_NETCONNECTION *connection, BOOL useSSL) { connection->useSSL = FALSE; connection->socketFD = -1; if (useSSL) { #if defined(SONAME_LIBSSL) && defined(SONAME_LIBCRYPTO) TRACE("using SSL connection\n"); if (OpenSSL_ssl_handle) /* already initialized everything */ return TRUE; OpenSSL_ssl_handle = wine_dlopen(SONAME_LIBSSL, RTLD_NOW, NULL, 0); if (!OpenSSL_ssl_handle) { ERR("trying to use a SSL connection, but couldn't load %s. Expect trouble.\n", SONAME_LIBSSL); INTERNET_SetLastError(ERROR_INTERNET_SECURITY_CHANNEL_ERROR); return FALSE; } OpenSSL_crypto_handle = wine_dlopen(SONAME_LIBCRYPTO, RTLD_NOW, NULL, 0); if (!OpenSSL_crypto_handle) { ERR("trying to use a SSL connection, but couldn't load %s. Expect trouble.\n", SONAME_LIBCRYPTO); INTERNET_SetLastError(ERROR_INTERNET_SECURITY_CHANNEL_ERROR); return FALSE; } /* mmm nice ugly macroness */ #define DYNSSL(x) \ p##x = wine_dlsym(OpenSSL_ssl_handle, #x, NULL, 0); \ if (!p##x) \ { \ ERR("failed to load symbol %s\n", #x); \ INTERNET_SetLastError(ERROR_INTERNET_SECURITY_CHANNEL_ERROR); \ return FALSE; \ } DYNSSL(SSL_library_init); DYNSSL(SSL_load_error_strings); DYNSSL(SSLv23_method); DYNSSL(SSL_CTX_new); DYNSSL(SSL_new); DYNSSL(SSL_free); DYNSSL(SSL_set_fd); DYNSSL(SSL_connect); DYNSSL(SSL_shutdown); DYNSSL(SSL_write); DYNSSL(SSL_read); DYNSSL(SSL_get_verify_result); DYNSSL(SSL_get_peer_certificate); DYNSSL(SSL_CTX_get_timeout); DYNSSL(SSL_CTX_set_timeout); DYNSSL(SSL_CTX_set_default_verify_paths); DYNSSL(i2d_X509); #undef DYNSSL #define DYNCRYPTO(x) \ p##x = wine_dlsym(OpenSSL_crypto_handle, #x, NULL, 0); \ if (!p##x) \ { \ ERR("failed to load symbol %s\n", #x); \ INTERNET_SetLastError(ERROR_INTERNET_SECURITY_CHANNEL_ERROR); \ return FALSE; \ } DYNCRYPTO(BIO_new_fp); DYNCRYPTO(ERR_get_error); DYNCRYPTO(ERR_error_string); #undef DYNCRYPTO pSSL_library_init(); pSSL_load_error_strings(); pBIO_new_fp(stderr, BIO_NOCLOSE); /* FIXME: should use winedebug stuff */ meth = pSSLv23_method(); connection->peek_msg = NULL; connection->peek_msg_mem = NULL; #else FIXME("can't use SSL, not compiled in.\n"); INTERNET_SetLastError(ERROR_INTERNET_SECURITY_CHANNEL_ERROR); return FALSE; #endif } return TRUE; }
static DWORD init_openssl(void) { #if defined(SONAME_LIBSSL) && defined(SONAME_LIBCRYPTO) int i; if(OpenSSL_ssl_handle) return ERROR_SUCCESS; OpenSSL_ssl_handle = wine_dlopen(SONAME_LIBSSL, RTLD_NOW, NULL, 0); if(!OpenSSL_ssl_handle) { ERR("trying to use a SSL connection, but couldn't load %s. Expect trouble.\n", SONAME_LIBSSL); return ERROR_INTERNET_SECURITY_CHANNEL_ERROR; } OpenSSL_crypto_handle = wine_dlopen(SONAME_LIBCRYPTO, RTLD_NOW, NULL, 0); if(!OpenSSL_crypto_handle) { ERR("trying to use a SSL connection, but couldn't load %s. Expect trouble.\n", SONAME_LIBCRYPTO); return ERROR_INTERNET_SECURITY_CHANNEL_ERROR; } /* mmm nice ugly macroness */ #define DYNSSL(x) \ p##x = wine_dlsym(OpenSSL_ssl_handle, #x, NULL, 0); \ if (!p##x) { \ ERR("failed to load symbol %s\n", #x); \ return ERROR_INTERNET_SECURITY_CHANNEL_ERROR; \ } DYNSSL(SSL_library_init); DYNSSL(SSL_load_error_strings); DYNSSL(SSLv23_method); DYNSSL(SSL_CTX_free); DYNSSL(SSL_CTX_new); DYNSSL(SSL_new); DYNSSL(SSL_free); DYNSSL(SSL_set_fd); DYNSSL(SSL_connect); DYNSSL(SSL_shutdown); DYNSSL(SSL_write); DYNSSL(SSL_read); DYNSSL(SSL_pending); DYNSSL(SSL_get_error); DYNSSL(SSL_get_ex_new_index); DYNSSL(SSL_get_ex_data); DYNSSL(SSL_set_ex_data); DYNSSL(SSL_get_ex_data_X509_STORE_CTX_idx); DYNSSL(SSL_get_peer_certificate); DYNSSL(SSL_CTX_get_timeout); DYNSSL(SSL_CTX_set_timeout); DYNSSL(SSL_CTX_set_default_verify_paths); DYNSSL(SSL_CTX_set_verify); DYNSSL(SSL_get_current_cipher); DYNSSL(SSL_CIPHER_get_bits); #undef DYNSSL #define DYNCRYPTO(x) \ p##x = wine_dlsym(OpenSSL_crypto_handle, #x, NULL, 0); \ if (!p##x) { \ ERR("failed to load symbol %s\n", #x); \ return ERROR_INTERNET_SECURITY_CHANNEL_ERROR; \ } DYNCRYPTO(BIO_new_fp); DYNCRYPTO(CRYPTO_num_locks); DYNCRYPTO(CRYPTO_set_id_callback); DYNCRYPTO(CRYPTO_set_locking_callback); DYNCRYPTO(ERR_free_strings); DYNCRYPTO(ERR_get_error); DYNCRYPTO(ERR_error_string); DYNCRYPTO(X509_STORE_CTX_get_ex_data); DYNCRYPTO(X509_STORE_CTX_get_chain); DYNCRYPTO(i2d_X509); DYNCRYPTO(sk_num); DYNCRYPTO(sk_value); #undef DYNCRYPTO pSSL_library_init(); pSSL_load_error_strings(); pBIO_new_fp(stderr, BIO_NOCLOSE); /* FIXME: should use winedebug stuff */ meth = pSSLv23_method(); ctx = pSSL_CTX_new(meth); if(!pSSL_CTX_set_default_verify_paths(ctx)) { ERR("SSL_CTX_set_default_verify_paths failed: %s\n", pERR_error_string(pERR_get_error(), 0)); return ERROR_OUTOFMEMORY; } hostname_idx = pSSL_get_ex_new_index(0, (void *)"hostname index", NULL, NULL, NULL); if(hostname_idx == -1) { ERR("SSL_get_ex_new_index failed; %s\n", pERR_error_string(pERR_get_error(), 0)); return ERROR_OUTOFMEMORY; } error_idx = pSSL_get_ex_new_index(0, (void *)"error index", NULL, NULL, NULL); if(error_idx == -1) { ERR("SSL_get_ex_new_index failed; %s\n", pERR_error_string(pERR_get_error(), 0)); return ERROR_OUTOFMEMORY; } conn_idx = pSSL_get_ex_new_index(0, (void *)"netconn index", NULL, NULL, NULL); if(conn_idx == -1) { ERR("SSL_get_ex_new_index failed; %s\n", pERR_error_string(pERR_get_error(), 0)); return ERROR_OUTOFMEMORY; } pSSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, netconn_secure_verify); pCRYPTO_set_id_callback(ssl_thread_id); num_ssl_locks = pCRYPTO_num_locks(); ssl_locks = heap_alloc(num_ssl_locks * sizeof(CRITICAL_SECTION)); if(!ssl_locks) return ERROR_OUTOFMEMORY; for(i = 0; i < num_ssl_locks; i++) { InitializeCriticalSection(&ssl_locks[i]); ssl_locks[i].DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": ssl_locks"); } pCRYPTO_set_locking_callback(ssl_lock_callback); return ERROR_SUCCESS; #else FIXME("can't use SSL, not compiled in.\n"); return ERROR_INTERNET_SECURITY_CHANNEL_ERROR; #endif }
void X11DRV_XF86VM_Init(void) { void *xvidmode_handle; Bool ok; int nmodes; unsigned int i; if (xf86vm_major) return; /* already initialized? */ xvidmode_handle = wine_dlopen(SONAME_LIBXXF86VM, RTLD_NOW, NULL, 0); if (!xvidmode_handle) { TRACE("Unable to open %s, XVidMode disabled\n", SONAME_LIBXXF86VM); usexvidmode = 0; return; } #define LOAD_FUNCPTR(f) \ if((p##f = wine_dlsym(xvidmode_handle, #f, NULL, 0)) == NULL) \ goto sym_not_found; LOAD_FUNCPTR(XF86VidModeGetAllModeLines) LOAD_FUNCPTR(XF86VidModeGetModeLine) LOAD_FUNCPTR(XF86VidModeLockModeSwitch) LOAD_FUNCPTR(XF86VidModeQueryExtension) LOAD_FUNCPTR(XF86VidModeQueryVersion) LOAD_FUNCPTR(XF86VidModeSetViewPort) LOAD_FUNCPTR(XF86VidModeSwitchToMode) #ifdef X_XF86VidModeSetGamma LOAD_FUNCPTR(XF86VidModeGetGamma) LOAD_FUNCPTR(XF86VidModeSetGamma) #endif #ifdef X_XF86VidModeSetGammaRamp LOAD_FUNCPTR(XF86VidModeGetGammaRamp) LOAD_FUNCPTR(XF86VidModeGetGammaRampSize) LOAD_FUNCPTR(XF86VidModeSetGammaRamp) #endif #undef LOAD_FUNCPTR /* see if XVidMode is available */ wine_tsx11_lock(); ok = pXF86VidModeQueryExtension(gdi_display, &xf86vm_event, &xf86vm_error); wine_tsx11_unlock(); if (!ok) return; X11DRV_expect_error(gdi_display, XVidModeErrorHandler, NULL); ok = pXF86VidModeQueryVersion(gdi_display, &xf86vm_major, &xf86vm_minor); if (X11DRV_check_error() || !ok) return; #ifdef X_XF86VidModeSetGammaRamp if (xf86vm_major > 2 || (xf86vm_major == 2 && xf86vm_minor >= 1)) { X11DRV_expect_error(gdi_display, XVidModeErrorHandler, NULL); pXF86VidModeGetGammaRampSize(gdi_display, DefaultScreen(gdi_display), &xf86vm_gammaramp_size); if (X11DRV_check_error()) xf86vm_gammaramp_size = 0; if (xf86vm_gammaramp_size == 256) xf86vm_use_gammaramp = TRUE; } #endif /* X_XF86VidModeSetGammaRamp */ /* retrieve modes */ if (usexvidmode && root_window == DefaultRootWindow( gdi_display )) { X11DRV_expect_error(gdi_display, XVidModeErrorHandler, NULL); ok = pXF86VidModeGetAllModeLines(gdi_display, DefaultScreen(gdi_display), &nmodes, &real_xf86vm_modes); if (X11DRV_check_error() || !ok) return; } else return; /* In desktop mode, do not switch resolution... But still use the Gamma ramp stuff */ TRACE("XVidMode modes: count=%d\n", nmodes); real_xf86vm_mode_count = nmodes; dd_modes = X11DRV_Settings_SetHandlers("XF86VidMode", X11DRV_XF86VM_GetCurrentMode, X11DRV_XF86VM_SetCurrentMode, nmodes, 1); /* convert modes to x11drv_mode_info format */ for (i=0; i<real_xf86vm_mode_count; i++) { convert_modeinfo(real_xf86vm_modes[i]); } /* add modes for different color depths */ X11DRV_Settings_AddDepthModes(); dd_mode_count = X11DRV_Settings_GetModeCount(); TRACE("Available DD modes: count=%d\n", dd_mode_count); TRACE("Enabling XVidMode\n"); return; sym_not_found: TRACE("Unable to load function pointers from %s, XVidMode disabled\n", SONAME_LIBXXF86VM); wine_dlclose(xvidmode_handle, NULL, 0); xvidmode_handle = NULL; usexvidmode = 0; }
BOOL schan_imp_init(void) { int ret; libgnutls_handle = wine_dlopen(SONAME_LIBGNUTLS, RTLD_NOW, NULL, 0); if (!libgnutls_handle) { WARN("Failed to load libgnutls.\n"); return FALSE; } #define LOAD_FUNCPTR(f) \ if (!(p##f = wine_dlsym(libgnutls_handle, #f, NULL, 0))) \ { \ ERR("Failed to load %s\n", #f); \ goto fail; \ } LOAD_FUNCPTR(gnutls_alert_get) LOAD_FUNCPTR(gnutls_alert_get_name) LOAD_FUNCPTR(gnutls_certificate_allocate_credentials) LOAD_FUNCPTR(gnutls_certificate_free_credentials) LOAD_FUNCPTR(gnutls_certificate_get_peers) LOAD_FUNCPTR(gnutls_cipher_get) LOAD_FUNCPTR(gnutls_cipher_get_key_size) LOAD_FUNCPTR(gnutls_credentials_set) LOAD_FUNCPTR(gnutls_deinit) LOAD_FUNCPTR(gnutls_global_deinit) LOAD_FUNCPTR(gnutls_global_init) LOAD_FUNCPTR(gnutls_global_set_log_function) LOAD_FUNCPTR(gnutls_global_set_log_level) LOAD_FUNCPTR(gnutls_handshake) LOAD_FUNCPTR(gnutls_init) LOAD_FUNCPTR(gnutls_kx_get) LOAD_FUNCPTR(gnutls_mac_get) LOAD_FUNCPTR(gnutls_mac_get_key_size) LOAD_FUNCPTR(gnutls_perror) LOAD_FUNCPTR(gnutls_protocol_get_version) LOAD_FUNCPTR(gnutls_set_default_priority) LOAD_FUNCPTR(gnutls_record_get_max_size); LOAD_FUNCPTR(gnutls_record_recv); LOAD_FUNCPTR(gnutls_record_send); LOAD_FUNCPTR(gnutls_transport_get_ptr) LOAD_FUNCPTR(gnutls_transport_set_errno) LOAD_FUNCPTR(gnutls_transport_set_ptr) LOAD_FUNCPTR(gnutls_transport_set_pull_function) LOAD_FUNCPTR(gnutls_transport_set_push_function) #undef LOAD_FUNCPTR ret = pgnutls_global_init(); if (ret != GNUTLS_E_SUCCESS) { pgnutls_perror(ret); goto fail; } if (TRACE_ON(secur32)) { pgnutls_global_set_log_level(4); pgnutls_global_set_log_function(schan_gnutls_log); } return TRUE; fail: wine_dlclose(libgnutls_handle, NULL, 0); libgnutls_handle = NULL; return FALSE; }
static void load_libopenal(void) { DWORD failed = 0; #ifdef SONAME_LIBOPENAL char error[128]; openal_handle = wine_dlopen(SONAME_LIBOPENAL, RTLD_NOW, error, sizeof(error)); if (!openal_handle) { ERR("Couldn't load " SONAME_LIBOPENAL ": %s\n", error); return; } #define LOAD_FUNCPTR(f) \ if((p##f = wine_dlsym(openal_handle, #f, NULL, 0)) == NULL) { \ ERR("Couldn't lookup %s in libopenal\n", #f); \ failed = 1; \ } LOAD_FUNCPTR(alcCreateContext); LOAD_FUNCPTR(alcMakeContextCurrent); LOAD_FUNCPTR(alcProcessContext); LOAD_FUNCPTR(alcSuspendContext); LOAD_FUNCPTR(alcDestroyContext); LOAD_FUNCPTR(alcGetCurrentContext); LOAD_FUNCPTR(alcGetContextsDevice); LOAD_FUNCPTR(alcOpenDevice); LOAD_FUNCPTR(alcCloseDevice); LOAD_FUNCPTR(alcGetError); LOAD_FUNCPTR(alcIsExtensionPresent); LOAD_FUNCPTR(alcGetProcAddress); LOAD_FUNCPTR(alcGetEnumValue); LOAD_FUNCPTR(alcGetString); LOAD_FUNCPTR(alcGetIntegerv); LOAD_FUNCPTR(alcCaptureOpenDevice); LOAD_FUNCPTR(alcCaptureCloseDevice); LOAD_FUNCPTR(alcCaptureStart); LOAD_FUNCPTR(alcCaptureStop); LOAD_FUNCPTR(alcCaptureSamples); LOAD_FUNCPTR(alEnable); LOAD_FUNCPTR(alDisable); LOAD_FUNCPTR(alIsEnabled); LOAD_FUNCPTR(alGetString); LOAD_FUNCPTR(alGetBooleanv); LOAD_FUNCPTR(alGetIntegerv); LOAD_FUNCPTR(alGetFloatv); LOAD_FUNCPTR(alGetDoublev); LOAD_FUNCPTR(alGetBoolean); LOAD_FUNCPTR(alGetInteger); LOAD_FUNCPTR(alGetFloat); LOAD_FUNCPTR(alGetDouble); LOAD_FUNCPTR(alGetError); LOAD_FUNCPTR(alIsExtensionPresent); LOAD_FUNCPTR(alGetProcAddress); LOAD_FUNCPTR(alGetEnumValue); LOAD_FUNCPTR(alListenerf); LOAD_FUNCPTR(alListener3f); LOAD_FUNCPTR(alListenerfv); LOAD_FUNCPTR(alListeneri); LOAD_FUNCPTR(alListener3i); LOAD_FUNCPTR(alListeneriv); LOAD_FUNCPTR(alGetListenerf); LOAD_FUNCPTR(alGetListener3f); LOAD_FUNCPTR(alGetListenerfv); LOAD_FUNCPTR(alGetListeneri); LOAD_FUNCPTR(alGetListener3i); LOAD_FUNCPTR(alGetListeneriv); LOAD_FUNCPTR(alGenSources); LOAD_FUNCPTR(alDeleteSources); LOAD_FUNCPTR(alIsSource); LOAD_FUNCPTR(alSourcef); LOAD_FUNCPTR(alSource3f); LOAD_FUNCPTR(alSourcefv); LOAD_FUNCPTR(alSourcei); LOAD_FUNCPTR(alSource3i); LOAD_FUNCPTR(alSourceiv); LOAD_FUNCPTR(alGetSourcef); LOAD_FUNCPTR(alGetSource3f); LOAD_FUNCPTR(alGetSourcefv); LOAD_FUNCPTR(alGetSourcei); LOAD_FUNCPTR(alGetSource3i); LOAD_FUNCPTR(alGetSourceiv); LOAD_FUNCPTR(alSourcePlayv); LOAD_FUNCPTR(alSourceStopv); LOAD_FUNCPTR(alSourceRewindv); LOAD_FUNCPTR(alSourcePausev); LOAD_FUNCPTR(alSourcePlay); LOAD_FUNCPTR(alSourceStop); LOAD_FUNCPTR(alSourceRewind); LOAD_FUNCPTR(alSourcePause); LOAD_FUNCPTR(alSourceQueueBuffers); LOAD_FUNCPTR(alSourceUnqueueBuffers); LOAD_FUNCPTR(alGenBuffers); LOAD_FUNCPTR(alDeleteBuffers); LOAD_FUNCPTR(alIsBuffer); LOAD_FUNCPTR(alBufferf); LOAD_FUNCPTR(alBuffer3f); LOAD_FUNCPTR(alBufferfv); LOAD_FUNCPTR(alBufferi); LOAD_FUNCPTR(alBuffer3i); LOAD_FUNCPTR(alBufferiv); LOAD_FUNCPTR(alGetBufferf); LOAD_FUNCPTR(alGetBuffer3f); LOAD_FUNCPTR(alGetBufferfv); LOAD_FUNCPTR(alGetBufferi); LOAD_FUNCPTR(alGetBuffer3i); LOAD_FUNCPTR(alGetBufferiv); LOAD_FUNCPTR(alBufferData); LOAD_FUNCPTR(alDopplerFactor); LOAD_FUNCPTR(alDopplerVelocity); LOAD_FUNCPTR(alDistanceModel); LOAD_FUNCPTR(alSpeedOfSound); #undef LOAD_FUNCPTR #endif if (failed) { WARN("Unloading openal\n"); if (openal_handle != RTLD_DEFAULT) wine_dlclose(openal_handle, NULL, 0); openal_handle = NULL; openal_loaded = 0; } else { openal_loaded = 1; local_contexts = palcIsExtensionPresent(NULL, "ALC_EXT_thread_local_context"); if (local_contexts) { set_context = palcGetProcAddress(NULL, "alcSetThreadContext"); get_context = palcGetProcAddress(NULL, "alcGetThreadContext"); if (!set_context || !get_context) { ERR("TLS advertised but functions not found, disabling thread local context\n"); local_contexts = 0; } } if (!local_contexts) { set_context = palcMakeContextCurrent; get_context = palcGetCurrentContext; } } }
/******************************************************************************* * PSDRV_GetTrueTypeMetrics * * Reads font metrics from TrueType font files in directories listed in the * [TrueType Font Directories] section of the Wine configuration file. * * If this function fails (returns FALSE), the driver will fail to initialize * and the driver heap will be destroyed, so it's not necessary to HeapFree * everything in that event. * */ BOOL PSDRV_GetTrueTypeMetrics(void) { static const WCHAR pathW[] = {'P','a','t','h',0}; FT_Error error; FT_Library library; HKEY hkey; DWORD len; LPWSTR valueW; LPSTR valueA, ptr; /* @@ Wine registry key: HKCU\Software\Wine\Fonts */ if (RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Fonts", &hkey) != ERROR_SUCCESS) return TRUE; ft_handle = wine_dlopen(SONAME_LIBFREETYPE, RTLD_NOW, NULL, 0); if(!ft_handle) { WINE_MESSAGE( "Wine cannot find the FreeType font library. To enable Wine to\n" "use TrueType fonts please install a version of FreeType greater than\n" "or equal to 2.0.5.\n" "http://www.freetype.org\n"); RegCloseKey(hkey); return TRUE; } #define LOAD_FUNCPTR(f) if((p##f = wine_dlsym(ft_handle, #f, NULL, 0)) == NULL) goto sym_not_found; LOAD_FUNCPTR(FT_Done_Face) LOAD_FUNCPTR(FT_Done_FreeType) LOAD_FUNCPTR(FT_Get_Char_Index) LOAD_FUNCPTR(FT_Get_Glyph_Name) LOAD_FUNCPTR(FT_Get_Sfnt_Name) LOAD_FUNCPTR(FT_Get_Sfnt_Name_Count) LOAD_FUNCPTR(FT_Get_Sfnt_Table) LOAD_FUNCPTR(FT_Init_FreeType) LOAD_FUNCPTR(FT_Load_Glyph) LOAD_FUNCPTR(FT_New_Face) LOAD_FUNCPTR(FT_Set_Charmap) #undef LOAD_FUNCPTR error = pFT_Init_FreeType(&library); if (error != FT_Err_Ok) { ERR("%s returned %i\n", "FT_Init_FreeType", error); wine_dlclose(ft_handle, NULL, 0); RegCloseKey(hkey); return FALSE; } if (RegQueryValueExW( hkey, pathW, NULL, NULL, NULL, &len ) == ERROR_SUCCESS) { len += sizeof(WCHAR); valueW = HeapAlloc( GetProcessHeap(), 0, len ); if (RegQueryValueExW( hkey, pathW, NULL, NULL, (LPBYTE)valueW, &len ) == ERROR_SUCCESS) { len = WideCharToMultiByte( CP_UNIXCP, 0, valueW, -1, NULL, 0, NULL, NULL ); valueA = HeapAlloc( GetProcessHeap(), 0, len ); WideCharToMultiByte( CP_UNIXCP, 0, valueW, -1, valueA, len, NULL, NULL ); TRACE( "got font path %s\n", debugstr_a(valueA) ); ptr = valueA; while (ptr) { LPSTR next = strchr( ptr, ':' ); if (next) *next++ = 0; ReadTrueTypeDir( library, ptr ); ptr = next; } HeapFree( GetProcessHeap(), 0, valueA ); } HeapFree( GetProcessHeap(), 0, valueW ); } RegCloseKey(hkey); pFT_Done_FreeType(library); wine_dlclose(ft_handle, NULL, 0); ft_handle = NULL; return TRUE; sym_not_found: WINE_MESSAGE( "Wine cannot find certain functions that it needs inside the FreeType\n" "font library. To enable Wine to use TrueType fonts please upgrade\n" "FreeType to at least version 2.0.5.\n" "http://www.freetype.org\n"); RegCloseKey(hkey); wine_dlclose(ft_handle, NULL, 0); ft_handle = NULL; return TRUE; }