Example #1
0
void X11_Vulkan_UnloadLibrary(_THIS)
{
    SDL_VideoData *videoData = (SDL_VideoData *)_this->driverdata;
    if(_this->vulkan_config.loader_handle)
    {
        if(videoData->vulkan_xlib_xcb_library)
            SDL_UnloadObject(videoData->vulkan_xlib_xcb_library);
        SDL_UnloadObject(_this->vulkan_config.loader_handle);
        _this->vulkan_config.loader_handle = NULL;
    }
}
Example #2
0
static void UnloadALSALibrary(void) {
	if (alsa_loaded) {
		SDL_UnloadObject(alsa_handle);
		alsa_handle = NULL;
		alsa_loaded = 0;
	}
}
Example #3
0
	void unloadPlugin() {
		DynamicPlugin::unloadPlugin();
		if (_dlHandle) {
			SDL_UnloadObject(_dlHandle);
			_dlHandle = 0;
		}
	}
Example #4
0
SDL_bool 
DXGI_LoadDLL( void **pDXGIDLL , IDXGIFactory **pDXGIFactory )
{
	*pDXGIDLL = SDL_LoadObject("DXGI.DLL");
	if (*pDXGIDLL ) {
		HRESULT (WINAPI *CreateDXGI)( REFIID riid, void **ppFactory );

		CreateDXGI =
			(HRESULT (WINAPI *) (REFIID, void**)) SDL_LoadFunction(*pDXGIDLL,
			"CreateDXGIFactory");
		if (CreateDXGI) {
			GUID dxgiGUID = {0x7b7166ec,0x21c7,0x44ae,{0xb2,0x1a,0xc9,0xae,0x32,0x1a,0xe3,0x69}};
			if( !SUCCEEDED( CreateDXGI( &dxgiGUID, (void**)pDXGIFactory ))) {
				*pDXGIFactory = NULL;
			}
		}
		if (!*pDXGIFactory) {
			SDL_UnloadObject(*pDXGIDLL);
			*pDXGIDLL = NULL;
			return SDL_FALSE;
		}

		return SDL_TRUE;
	} else {
		*pDXGIFactory = NULL;
		return SDL_FALSE;
	}
}
Example #5
0
static void
D3D_DestroyRenderer(SDL_Renderer * renderer)
{
    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;

    if (data) {
        /* Release the render target */
        if (data->defaultRenderTarget) {
            IDirect3DSurface9_Release(data->defaultRenderTarget);
            data->defaultRenderTarget = NULL;
        }
        if (data->currentRenderTarget != NULL) {
            IDirect3DSurface9_Release(data->currentRenderTarget);
            data->currentRenderTarget = NULL;
        }

        if (data->device) {
            IDirect3DDevice9_Release(data->device);
        }
        if (data->d3d) {
            IDirect3D9_Release(data->d3d);
            ID3DXMatrixStack_Release(data->matrixStack);
            SDL_UnloadObject(data->d3dDLL);
        }
        SDL_free(data);
    }
    SDL_free(renderer);
}
static void
WIN_DeleteDevice(SDL_VideoDevice * device)
{
    SDL_VideoData *data = (SDL_VideoData *) device->driverdata;

    SDL_UnregisterApp();
    if (data->userDLL) {
        SDL_UnloadObject(data->userDLL);
    }
    if (data->shcoreDLL) {
        SDL_UnloadObject(data->shcoreDLL);
    }

    SDL_free(device->driverdata);
    SDL_free(device);
}
Example #7
0
void
SDL_X11_UnloadSymbols(void)
{
    /* Don't actually unload if more than one module is using the libs... */
    if (x11_load_refcount > 0) {
        if (--x11_load_refcount == 0) {
            int i;

            /* set all the function pointers to NULL. */
#define SDL_X11_MODULE(modname) SDL_X11_HAVE_##modname = 0;
#define SDL_X11_SYM(rc,fn,params,args,ret) X11_##fn = NULL;
#include "SDL_x11sym.h"

#ifdef X_HAVE_UTF8_STRING
            X11_XCreateIC = NULL;
            X11_XGetICValues = NULL;
#endif

#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC
            for (i = 0; i < SDL_TABLESIZE(x11libs); i++) {
                if (x11libs[i].lib != NULL) {
                    SDL_UnloadObject(x11libs[i].lib);
                    x11libs[i].lib = NULL;
                }
            }
#endif
        }
    }
}
Example #8
0
void
SDL_WAYLAND_UnloadSymbols(void)
{
    /* Don't actually unload if more than one module is using the libs... */
    if (wayland_load_refcount > 0) {
        if (--wayland_load_refcount == 0) {
#ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC            
            int i;
#endif
            
            /* set all the function pointers to NULL. */
#define SDL_WAYLAND_MODULE(modname) SDL_WAYLAND_HAVE_##modname = 0;
#define SDL_WAYLAND_SYM(rc,fn,params) WAYLAND_##fn = NULL;
#define SDL_WAYLAND_INTERFACE(iface) WAYLAND_##iface = NULL;
#include "SDL_waylandsym.h"


#ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC
            for (i = 0; i < SDL_TABLESIZE(waylandlibs); i++) {
                if (waylandlibs[i].lib != NULL) {
                    SDL_UnloadObject(waylandlibs[i].lib);
                    waylandlibs[i].lib = NULL;
                }
            }
#endif
        }
    }
}
Example #9
0
void
SDL_MIR_UnloadSymbols(void)
{
    /* Don't actually unload if more than one module is using the libs... */
    if (mir_load_refcount > 0) {
        if (--mir_load_refcount == 0) {
#ifdef SDL_VIDEO_DRIVER_MIR_DYNAMIC            
            int i;
#endif
            
            /* set all the function pointers to NULL. */
#define SDL_MIR_MODULE(modname) SDL_MIR_HAVE_##modname = 0;
#define SDL_MIR_SYM(rc,fn,params) MIR_##fn = NULL;
#include "SDL_mirsym.h"
#undef SDL_MIR_MODULE
#undef SDL_MIR_SYM


#ifdef SDL_VIDEO_DRIVER_MIR_DYNAMIC
            for (i = 0; i < SDL_TABLESIZE(mirlibs); i++) {
                if (mirlibs[i].lib != NULL) {
                    SDL_UnloadObject(mirlibs[i].lib);
                    mirlibs[i].lib = NULL;
                }
            }
#endif
        }
    }
}
	PluginManager::~PluginManager()
	{
		for (void* p : _plugins)
		{
			SDL_UnloadObject(p);
		}
	}
/** Calls a function with no args and no return value in the specified DLL */
void CallNoArgNotification( const char *pchModuleName, const char *pchProcName )
{
#if defined(_WIN32)
	void * pMod = (void *)GetModuleHandle( pchModuleName );
	if( pMod )
	{
		NoArgNotificationFn_t fn = (NoArgNotificationFn_t)SDL_LoadFunction( pMod, pchProcName );
#elif defined(POSIX)
        // on POSIX there is no reasonable way to get the handle of a module without the
        // full path name. Since we don't know that, just assume that the global symbol
        // name is only defined in the right module
        NoArgNotificationFn_t fn = (NoArgNotificationFn_t)SDL_LoadFunction( NULL, pchProcName );
#endif
		if( fn )
		{
			// actually call the function
			fn();
		}

#if defined(_WIN32)
		// unload the module to free up the reference that was returned by SDL_GetLoadedObject
		SDL_UnloadObject( pMod );
	}
#endif

}
Example #12
0
SDL_bool 
D3D_LoadDLL( void **pD3DDLL, IDirect3D9 **pDirect3D9Interface )
{
	*pD3DDLL = SDL_LoadObject("D3D9.DLL");
	if (*pD3DDLL) {
		IDirect3D9 *(WINAPI * D3DCreate) (UINT SDKVersion);

		D3DCreate =
			(IDirect3D9 * (WINAPI *) (UINT)) SDL_LoadFunction(*pD3DDLL,
			"Direct3DCreate9");
		if (D3DCreate) {
			*pDirect3D9Interface = D3DCreate(D3D_SDK_VERSION);
		}
		if (!*pDirect3D9Interface) {
			SDL_UnloadObject(*pD3DDLL);
			*pD3DDLL = NULL;
			return SDL_FALSE;
		}

		return SDL_TRUE;
	} else {
		*pDirect3D9Interface = NULL;
		return SDL_FALSE;
	}
}
Example #13
0
void Mac_GL_UnloadLibrary(_THIS)
{
	SDL_UnloadObject(this->hidden->libraryHandle);

	this->hidden->libraryHandle = NULL;
	this->gl_config.driver_loaded = 0;
}
Example #14
0
int IMG_InitTIF()
{
	if ( lib.loaded == 0 ) {
		lib.handle = SDL_LoadObject(LOAD_TIF_DYNAMIC);
		if ( lib.handle == NULL ) {
			return -1;
		}
		lib.TIFFClientOpen =
			(TIFF* (*)(const char*, const char*, thandle_t, TIFFReadWriteProc, TIFFReadWriteProc, TIFFSeekProc, TIFFCloseProc, TIFFSizeProc, TIFFMapFileProc, TIFFUnmapFileProc))
			SDL_LoadFunction(lib.handle, "TIFFClientOpen");
		if ( lib.TIFFClientOpen == NULL ) {
			SDL_UnloadObject(lib.handle);
			return -1;
		}
		lib.TIFFClose =
			(void (*)(TIFF*))
			SDL_LoadFunction(lib.handle, "TIFFClose");
		if ( lib.TIFFClose == NULL ) {
			SDL_UnloadObject(lib.handle);
			return -1;
		}
		lib.TIFFGetField =
			(int (*)(TIFF*, ttag_t, ...))
			SDL_LoadFunction(lib.handle, "TIFFGetField");
		if ( lib.TIFFGetField == NULL ) {
			SDL_UnloadObject(lib.handle);
			return -1;
		}
		lib.TIFFReadRGBAImage =
			(int (*)(TIFF*, uint32, uint32, uint32*, int))
			SDL_LoadFunction(lib.handle, "TIFFReadRGBAImage");
		if ( lib.TIFFReadRGBAImage == NULL ) {
			SDL_UnloadObject(lib.handle);
			return -1;
		}
		lib.TIFFSetErrorHandler =
			(TIFFErrorHandler (*)(TIFFErrorHandler))
			SDL_LoadFunction(lib.handle, "TIFFSetErrorHandler");
		if ( lib.TIFFSetErrorHandler == NULL ) {
			SDL_UnloadObject(lib.handle);
			return -1;
		}
	}
	++lib.loaded;

	return 0;
}
Example #15
0
int
main(int argc, char *argv[])
{
    int retval = 0;
    int hello = 0;
    const char *libname = NULL;
    const char *symname = NULL;
    void *lib = NULL;
    fntype fn = NULL;

    if (argc != 3) {
        const char *app = argv[0];
        SDL_Log("USAGE: %s <library> <functionname>\n", app);
        SDL_Log("       %s --hello <lib with puts()>\n", app);
        return 1;
    }

    /* Initialize SDL */
    if (SDL_Init(0) < 0) {
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
        return 2;
    }

    if (strcmp(argv[1], "--hello") == 0) {
        hello = 1;
        libname = argv[2];
        symname = "puts";
    } else {
        libname = argv[1];
        symname = argv[2];
    }

    lib = SDL_LoadObject(libname);
    if (lib == NULL) {
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_LoadObject('%s') failed: %s\n",
                libname, SDL_GetError());
        retval = 3;
    } else {
        fn = (fntype) SDL_LoadFunction(lib, symname);
        if (fn == NULL) {
            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_LoadFunction('%s') failed: %s\n",
                    symname, SDL_GetError());
            retval = 4;
        } else {
            SDL_Log("Found %s in %s at %p\n", symname, libname, fn);
            if (hello) {
                SDL_Log("Calling function...\n");
                fflush(stdout);
                fn("     HELLO, WORLD!\n");
                SDL_Log("...apparently, we survived.  :)\n");
                SDL_Log("Unloading library...\n");
                fflush(stdout);
            }
        }
        SDL_UnloadObject(lib);
    }
    SDL_Quit();
    return retval;
}
int
WIN_GL_LoadLibrary(_THIS, const char *path)
{
    LPTSTR wpath;
    HANDLE handle;

    if (path == NULL) {
        path = SDL_getenv("SDL_OPENGL_LIBRARY");
    }
    if (path == NULL) {
        path = DEFAULT_OPENGL;
    }
    wpath = WIN_UTF8ToString(path);
    _this->gl_config.dll_handle = LoadLibrary(wpath);
    SDL_free(wpath);
    if (!_this->gl_config.dll_handle) {
        char message[1024];
        SDL_snprintf(message, SDL_arraysize(message), "LoadLibrary(\"%s\")",
                     path);
        WIN_SetError(message);
        return -1;
    }
    SDL_strlcpy(_this->gl_config.driver_path, path,
                SDL_arraysize(_this->gl_config.driver_path));

    /* Allocate OpenGL memory */
    _this->gl_data =
        (struct SDL_GLDriverData *) SDL_calloc(1,
                                               sizeof(struct
                                                      SDL_GLDriverData));
    if (!_this->gl_data) {
        SDL_OutOfMemory();
        return -1;
    }

    /* Load function pointers */
    handle = _this->gl_config.dll_handle;
    _this->gl_data->wglGetProcAddress = (void *(WINAPI *) (const char *))
        GetProcAddress(handle, "wglGetProcAddress");
    _this->gl_data->wglCreateContext = (HGLRC(WINAPI *) (HDC))
        GetProcAddress(handle, "wglCreateContext");
    _this->gl_data->wglDeleteContext = (BOOL(WINAPI *) (HGLRC))
        GetProcAddress(handle, "wglDeleteContext");
    _this->gl_data->wglMakeCurrent = (BOOL(WINAPI *) (HDC, HGLRC))
        GetProcAddress(handle, "wglMakeCurrent");
    _this->gl_data->wglShareLists = (BOOL(WINAPI *) (HGLRC, HGLRC))
        GetProcAddress(handle, "wglShareLists");

    if (!_this->gl_data->wglGetProcAddress ||
        !_this->gl_data->wglCreateContext ||
        !_this->gl_data->wglDeleteContext ||
        !_this->gl_data->wglMakeCurrent) {
        SDL_SetError("Could not retrieve OpenGL functions");
        SDL_UnloadObject(handle);
        return -1;
    }

    return 0;
}
Example #17
0
void WIN_Vulkan_UnloadLibrary(_THIS)
{
    if(_this->vulkan_config.loader_handle)
    {
        SDL_UnloadObject(_this->vulkan_config.loader_handle);
        _this->vulkan_config.loader_handle = NULL;
    }
}
Example #18
0
static void
UnloadDBUSLibrary(void)
{
    if (dbus_handle != NULL) {
        SDL_UnloadObject(dbus_handle);
        dbus_handle = NULL;
    }
}
static void UnloadPulseLibrary()
{
	if ( pulse_loaded ) {
		SDL_UnloadObject(pulse_handle);
		pulse_handle = NULL;
		pulse_loaded = 0;
	}
}
Example #20
0
static void
UnloadESDLibrary()
{
    if (esd_handle != NULL) {
        SDL_UnloadObject(esd_handle);
        esd_handle = NULL;
    }
}
Example #21
0
static void
UnloadFusionSoundLibrary()
{
    if (fs_handle != NULL) {
        SDL_UnloadObject(fs_handle);
        fs_handle = NULL;
    }
}
Example #22
0
static void UnloadESDLibrary()
{
	if ( esd_loaded ) {
		SDL_UnloadObject(esd_handle);
		esd_handle = NULL;
		esd_loaded = 0;
	}
}
Example #23
0
static void
UnloadUDEVLibrary(void)
{
    if (udev_handle != NULL) {
        SDL_UnloadObject(udev_handle);
        udev_handle = NULL;
    }
}
static void
UnloadNASLibrary(void)
{
    if (nas_handle != NULL) {
        SDL_UnloadObject(nas_handle);
        nas_handle = NULL;
    }
}
Example #25
0
static void UnloadARTSLibrary()
{
	if ( arts_loaded ) {
		SDL_UnloadObject(arts_handle);
		arts_handle = NULL;
		arts_loaded = 0;
	}
}
Example #26
0
static void
UnloadSNDIOLibrary(void)
{
    if (sndio_handle != NULL) {
        SDL_UnloadObject(sndio_handle);
        sndio_handle = NULL;
    }
}
Example #27
0
static void
UnloadPulseAudioLibrary(void)
{
    if (pulseaudio_handle != NULL) {
        SDL_UnloadObject(pulseaudio_handle);
        pulseaudio_handle = NULL;
    }
}
Example #28
0
static void SV_UnloadGame (void)
{
#ifndef HARD_LINKED_GAME
	if (svs.gameLibrary) {
		Com_Printf("Unload the game library\n");
		SDL_UnloadObject(svs.gameLibrary);
	}
#endif
}
Example #29
0
void Mix_QuitOgg()
{
	if ( vorbis.loaded == 0 ) {
		return;
	}
	if ( vorbis.loaded == 1 ) {
		SDL_UnloadObject(vorbis.handle);
	}
	--vorbis.loaded;
}
Example #30
0
void Mix_QuitFLAC()
{
    if ( flac.loaded == 0 ) {
        return;
    }
    if ( flac.loaded == 1 ) {
        SDL_UnloadObject(flac.handle);
    }
    --flac.loaded;
}