[glib/nirbheek/preliminary-uwp-support] gmodule: Add support for loading UWP packaged DLLs
- From: Nirbheek Chauhan <nirbheekc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/nirbheek/preliminary-uwp-support] gmodule: Add support for loading UWP packaged DLLs
- Date: Tue, 25 Jun 2019 12:34:11 +0000 (UTC)
commit cb5e05ca6c9432b561eba14cba4ee79c408c5f84
Author: Nirbheek Chauhan <nirbheek centricular com>
Date: Mon May 6 19:13:35 2019 +0530
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.
gmodule/gmodule-win32.c | 8 ++++++++
1 file changed, 8 insertions(+)
---
diff --git a/gmodule/gmodule-win32.c b/gmodule/gmodule-win32.c
index 20459f372..da6bad6b4 100644
--- a/gmodule/gmodule-win32.c
+++ b/gmodule/gmodule-win32.c
@@ -84,7 +84,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 defined(_MSC_VER) && _WIN32_WINNT >= 0x0602 && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
+ handle = LoadPackagedLibrary (wfilename, 0);
+#else
handle = LoadLibraryW (wfilename);
+#endif
+
if (success)
SetThreadErrorMode (old_mode, NULL);
g_free (wfilename);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]