SDL
2.0
SDL_sysloadso.c
Go to the documentation of this file.
1
/*
2
Simple DirectMedia Layer
3
Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
4
5
This software is provided 'as-is', without any express or implied
6
warranty. In no event will the authors be held liable for any damages
7
arising from the use of this software.
8
9
Permission is granted to anyone to use this software for any purpose,
10
including commercial applications, and to alter it and redistribute it
11
freely, subject to the following restrictions:
12
13
1. The origin of this software must not be misrepresented; you must not
14
claim that you wrote the original software. If you use this software
15
in a product, an acknowledgment in the product documentation would be
16
appreciated but is not required.
17
2. Altered source versions must be plainly marked as such, and must not be
18
misrepresented as being the original software.
19
3. This notice may not be removed or altered from any source distribution.
20
*/
21
#include "../../SDL_internal.h"
22
23
#ifdef SDL_LOADSO_WINDOWS
24
25
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
26
/* System dependent library loading routines */
27
28
#include "../../core/windows/SDL_windows.h"
29
30
#include "
SDL_loadso.h
"
31
32
void
*
33
SDL_LoadObject
(
const
char
*sofile)
34
{
35
LPTSTR tstr =
WIN_UTF8ToString
(sofile);
36
#ifdef __WINRT__
37
/* WinRT only publically supports LoadPackagedLibrary() for loading .dll
38
files. LoadLibrary() is a private API, and not available for apps
39
(that can be published to MS' Windows Store.)
40
*/
41
void
*
handle
= (
void
*) LoadPackagedLibrary(tstr, 0);
42
#else
43
void
*
handle
= (
void
*) LoadLibrary(tstr);
44
#endif
45
SDL_free
(tstr);
46
47
/* Generate an error message if all loads failed */
48
if
(
handle
==
NULL
) {
49
char
errbuf[512];
50
SDL_strlcpy
(errbuf,
"Failed loading "
,
SDL_arraysize
(errbuf));
51
SDL_strlcat
(errbuf, sofile,
SDL_arraysize
(errbuf));
52
WIN_SetError
(errbuf);
53
}
54
return
handle
;
55
}
56
57
void
*
58
SDL_LoadFunction
(
void
*
handle
,
const
char
*
name
)
59
{
60
void
*symbol = (
void
*) GetProcAddress((HMODULE)
handle
,
name
);
61
if
(symbol ==
NULL
) {
62
char
errbuf[512];
63
SDL_strlcpy
(errbuf,
"Failed loading "
,
SDL_arraysize
(errbuf));
64
SDL_strlcat
(errbuf,
name
,
SDL_arraysize
(errbuf));
65
WIN_SetError
(errbuf);
66
}
67
return
symbol;
68
}
69
70
void
71
SDL_UnloadObject
(
void
*
handle
)
72
{
73
if
(
handle
!=
NULL
) {
74
FreeLibrary((HMODULE)
handle
);
75
}
76
}
77
78
#endif
/* SDL_LOADSO_WINDOWS */
79
80
/* vi: set ts=4 sw=4 expandtab: */
SDL_strlcat
#define SDL_strlcat
Definition:
SDL_dynapi_overrides.h:396
SDL_strlcpy
#define SDL_strlcpy
Definition:
SDL_dynapi_overrides.h:394
WIN_UTF8ToString
#define WIN_UTF8ToString(S)
Definition:
SDL_windows.h:47
NULL
#define NULL
Definition:
begin_code.h:164
handle
EGLImageKHR EGLint EGLint * handle
Definition:
eglext.h:937
SDL_UnloadObject
#define SDL_UnloadObject
Definition:
SDL_dynapi_overrides.h:234
SDL_LoadObject
#define SDL_LoadObject
Definition:
SDL_dynapi_overrides.h:232
SDL_free
#define SDL_free
Definition:
SDL_dynapi_overrides.h:377
name
GLuint const GLchar * name
Definition:
SDL_opengl_glext.h:660
SDL_arraysize
#define SDL_arraysize(array)
Definition:
SDL_stdinc.h:115
WIN_SetError
int WIN_SetError(const char *prefix)
SDL_LoadFunction
void * SDL_LoadFunction(void *handle, const char *name)
SDL_loadso.h
src
loadso
windows
SDL_sysloadso.c
Generated by
1.8.20