mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +01:00
gmodule: Add support for loading UWP packaged DLLs
LoadLibrary() is not available when building for the Universal Windows Platform, which is used for shipping apps to the Windows Store on all devices (Windows Desktop, Windows Phone, Surface, XBox, etc). Apps are not allowed to load arbitrary DLLs from the system. The only DLLs they can load are those that are bundled with the app as assets. LoadPackagedLibrary() can be used to access those assets by filename. The function is meant to be a drop-in replacement for LoadLibrary(), and the HANDLE returned can be treated the same as before.
This commit is contained in:
parent
cdc2a798cf
commit
be56d90fe9
@ -39,6 +39,12 @@
|
||||
#include <sys/cygwin.h>
|
||||
#endif
|
||||
|
||||
/* Default family is DESKTOP_APP which is DESKTOP | APP
|
||||
* We want to know when we're only building for apps */
|
||||
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
||||
#define G_WINAPI_ONLY_APP
|
||||
#endif
|
||||
|
||||
static void
|
||||
set_error (const gchar *format,
|
||||
...)
|
||||
@ -84,7 +90,15 @@ _g_module_open (const gchar *file_name,
|
||||
success = SetThreadErrorMode (SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS, &old_mode);
|
||||
if (!success)
|
||||
set_error ("");
|
||||
|
||||
/* When building for UWP, load app asset DLLs instead of filesystem DLLs.
|
||||
* Needs MSVC, Windows 8 and newer, and is only usable from apps. */
|
||||
#if _WIN32_WINNT >= 0x0602 && defined(G_WINAPI_ONLY_APP)
|
||||
handle = LoadPackagedLibrary (wfilename, 0);
|
||||
#else
|
||||
handle = LoadLibraryW (wfilename);
|
||||
#endif
|
||||
|
||||
if (success)
|
||||
SetThreadErrorMode (old_mode, NULL);
|
||||
g_free (wfilename);
|
||||
|
Loading…
Reference in New Issue
Block a user