WinRT: added support for the SDL_loadso APIs, via LoadPackagedLibrary

This commit is contained in:
David Ludwig 2012-12-31 10:30:38 -05:00
parent cc456a7516
commit 1ce8f1c824
4 changed files with 24 additions and 5 deletions

View file

@ -53,6 +53,7 @@
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
</ClCompile>
<ClCompile Include="..\..\src\core\windows\SDL_windows.c" />
<ClCompile Include="..\..\src\cpuinfo\SDL_cpuinfo.c" />
<ClCompile Include="..\..\src\events\SDL_clipboardevents.c" />
<ClCompile Include="..\..\src\events\SDL_dropevents.c" />
@ -68,6 +69,7 @@
<ClCompile Include="..\..\src\haptic\SDL_haptic.c" />
<ClCompile Include="..\..\src\joystick\dummy\SDL_sysjoystick.c" />
<ClCompile Include="..\..\src\joystick\SDL_joystick.c" />
<ClCompile Include="..\..\src\loadso\windows\SDL_sysloadso.c" />
<ClCompile Include="..\..\src\render\SDL_render.c" />
<ClCompile Include="..\..\src\render\SDL_yuv_mmx.c" />
<ClCompile Include="..\..\src\render\SDL_yuv_sw.c" />

View file

@ -146,9 +146,7 @@ typedef unsigned int uintptr_t;
#define SDL_JOYSTICK_DISABLED 1
/* Enable various shared object loading systems */
// TODO, WinRT: adapt the Win32 shared object loading code for WinRT
#define SDL_LOADSO_DISABLED 1
//#define SDL_LOADSO_WINDOWS 1
#define SDL_LOADSO_WINDOWS 1
/* Enable various threading systems */
#define SDL_THREAD_STDCPP 1

View file

@ -20,12 +20,12 @@
*/
#include "SDL_config.h"
#ifdef __WIN32__
#if defined(__WIN32__) || defined(__WINRT__)
#include "SDL_error.h"
#include "SDL_windows.h"
#include <objbase.h> /* for CoInitialize/CoUninitialize */
#include <objbase.h> /* for CoInitialize/CoUninitialize (Win32 only) */
/* Sets an error message based on GetLastError() */
@ -44,6 +44,14 @@ WIN_SetError(const char *prefix)
HRESULT
WIN_CoInitialize(void)
{
#ifdef __WINRT__
/* DLudwig: On WinRT, it is assumed that COM was initialized in main().
CoInitializeEx is available (not CoInitialize though), however
on WinRT, main() is typically declared with the [MTAThread]
attribute, which, AFAIK, should initialize COM.
*/
return S_OK;
#else
const HRESULT hr = CoInitialize(NULL);
/* S_FALSE means success, but someone else already initialized. */
@ -53,12 +61,15 @@ WIN_CoInitialize(void)
}
return hr;
#endif
}
void
WIN_CoUninitialize(void)
{
#ifndef __WINRT__
CoUninitialize();
#endif
}
#endif /* __WIN32__ */

View file

@ -33,7 +33,15 @@ void *
SDL_LoadObject(const char *sofile)
{
LPTSTR tstr = WIN_UTF8ToString(sofile);
#ifdef __WINRT__
/* WinRT only publically supports LoadPackagedLibrary() for loading .dll
files. LoadLibrary() is a private API, and not available for apps
(that can be published to MS' Windows Store.)
*/
void *handle = (void *) LoadPackagedLibrary(tstr, 0);
#else
void *handle = (void *) LoadLibrary(tstr);
#endif
SDL_free(tstr);
/* Generate an error message if all loads failed */