1- From 6944869021af1f4f5585d7e54aaf0e8d971d0afd Mon Sep 17 00:00:00 2001
2- From: Alwin Esch <alwin.esch@web.de>
3- Date: Thu, 22 Aug 2019 19:30:12 +0100
4- Subject: [PATCH] [win10] fixed uwp build
5-
6- ---
7- src/dlfcn.c | 47 +++++++++++++++++++++++++++++++++++++++++------
8- 1 file changed, 41 insertions(+), 6 deletions(-)
9-
10- diff --git a/src/dlfcn.c b/src/dlfcn.c
11- index cb9f9bb..ce43ae7 100644
12- --- a/src/dlfcn.c
13- +++ b/src/dlfcn.c
14- @@ -24,6 +24,7 @@
1+ From f85366b1044fff7b4ea9162c3edcd8278c3e06ff Mon Sep 17 00:00:00 2001
2+ From: Alwin Esch <alwin.esch@web.de>
3+ Date: Thu, 22 Aug 2019 19:30:12 +0100
4+ Subject: [PATCH] [win10] fixed uwp build
5+
6+ ---
7+
8+ diff --git a/src/dlfcn.c b/src/dlfcn.c
9+ index cb9f9bb..b26b404 100644
10+ --- a/src/dlfcn.c
11+ +++ b/src/dlfcn.c
12+ @@ -24,6 +24,7 @@
1513 * THE SOFTWARE.
1614 */
1715
1816+ #define _CRT_SECURE_NO_WARNINGS
1917 #ifdef _DEBUG
2018 #define _CRTDBG_MAP_ALLOC
2119 #include <stdlib.h>
22- @@ -311,6 +312,7 @@ static HMODULE MyGetModuleHandleFromAddress( const void *addr )
20+ @@ -311,6 +312,7 @@ static HMODULE MyGetModuleHandleFromAddress( const void *addr )
2321 /* Load Psapi.dll at runtime, this avoids linking caveat */
2422 static BOOL MyEnumProcessModules( HANDLE hProcess, HMODULE *lphModule, DWORD cb, LPDWORD lpcbNeeded )
2523 {
2624+ #if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY != WINAPI_FAMILY_APP)
2725 static BOOL (WINAPI *EnumProcessModulesPtr)(HANDLE, HMODULE *, DWORD, LPDWORD) = NULL;
2826 static BOOL failed = FALSE;
2927 UINT uMode;
30- @@ -349,21 +351,27 @@ static BOOL MyEnumProcessModules( HANDLE hProcess, HMODULE *lphModule, DWORD cb,
28+ @@ -349,21 +351,27 @@ static BOOL MyEnumProcessModules( HANDLE hProcess, HMODULE *lphModule, DWORD cb,
3129 }
3230
3331 return EnumProcessModulesPtr( hProcess, lphModule, cb, lpcbNeeded );
@@ -57,19 +55,18 @@ index cb9f9bb..ce43ae7 100644
5755 /* POSIX says that if the value of file is NULL, a handle on a global
5856 * symbol object must be provided. That object must be able to access
5957 * all symbols from the original program file, and any objects loaded
60- @@ -378,6 +386,7 @@ void *dlopen( const char *file, int mode )
58+ @@ -378,6 +386,7 @@ void *dlopen( const char *file, int mode )
6159
6260 if( !hModule )
6361 save_err_str( "(null)", GetLastError( ) );
6462+ #endif
6563 }
6664 else
6765 {
68- @@ -415,16 +424,35 @@ void *dlopen( const char *file, int mode )
66+ @@ -415,6 +424,23 @@ void *dlopen( const char *file, int mode )
6967 * to UNIX's search paths (start with system folders instead of current
7068 * folder).
7169 */
72- - hModule = LoadLibraryExA( lpFileName, NULL, LOAD_WITH_ALTERED_SEARCH_PATH );
7370+ #if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
7471+ int result = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, lpFileName, strlen(lpFileName), NULL, 0);
7572+ if (result == 0)
@@ -82,27 +79,20 @@ index cb9f9bb..ce43ae7 100644
8279+ free( newStr );
8380+ return NULL;
8481+ }
85-
82+ +
8683+ hModule = LoadPackagedLibrary( newStr, 0 );
8784+ free( newStr );
8885+ dwProcModsAfter = 0;
8986+ #else // WINAPI_PARTITION_DESKTOP
90- + hModule = LoadLibraryExA( lpFileName, NULL, LOAD_WITH_ALTERED_SEARCH_PATH );
91- + #endif
87+ hModule = LoadLibraryExA( lpFileName, NULL, LOAD_WITH_ALTERED_SEARCH_PATH );
88+
9289 if( !hModule )
93- {
94- save_err_str( lpFileName, GetLastError( ) );
90+ @@ -449,11 +475,14 @@ void *dlopen( const char *file, int mode )
91+ local_rem( hModule );
92+ }
9593 }
96- else
97- {
98- + #if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY != WINAPI_FAMILY_APP)
99- if( MyEnumProcessModules( hCurrentProc, NULL, 0, &dwProcModsAfter ) == 0 )
100- dwProcModsAfter = 0;
10194+ #endif
102-
103- /* If the object was loaded with RTLD_LOCAL, add it to list of local
104- * objects, so that its symbols cannot be retrieved even if the handle for
105- @@ -453,7 +481,9 @@ void *dlopen( const char *file, int mode )
95+ }
10696 }
10797
10898 /* Return to previous state of the error-mode bit flags. */
@@ -112,52 +102,47 @@ index cb9f9bb..ce43ae7 100644
112102
113103 return (void *) hModule;
114104 }
115- @@ -488,13 +518,15 @@ void *dlsym( void *handle, const char *name )
105+ @@ -488,15 +517,16 @@ void *dlsym( void *handle, const char *name )
116106 {
117107 FARPROC symbol;
118108 HMODULE hCaller;
119109- HMODULE hModule;
120- - DWORD dwMessageId;
121110+ HMODULE hModule = 0;
122- + DWORD dwMessageId = 0 ;
111+ DWORD dwMessageId;
123112
124113 error_occurred = FALSE;
125114
126115 symbol = NULL;
116+ + dwMessageId = 0;
127117 hCaller = NULL;
128- +
129118+ #if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY != WINAPI_FAMILY_APP) // what is replacement of GMH on UWP?
130119 hModule = GetModuleHandle( NULL );
131- dwMessageId = 0;
120+ - dwMessageId = 0;
132121
133- @@ -525,6 +557,7 @@ void *dlsym( void *handle, const char *name )
122+ if( handle == RTLD_DEFAULT )
123+ {
124+ @@ -525,6 +555,7 @@ void *dlsym( void *handle, const char *name )
134125 goto end;
135126 }
136127 }
137128+ #endif
138129
139130 if( handle != RTLD_NEXT )
140131 {
141- @@ -538,9 +571,10 @@ void *dlsym( void *handle, const char *name )
132+ @@ -537,7 +568,7 @@ void *dlsym( void *handle, const char *name )
133+ /* If the handle for the original program file is passed, also search
142134 * in all globally loaded objects.
143135 */
144-
136+ -
145137+ #if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY != WINAPI_FAMILY_APP)
146138 if( hModule == handle || handle == RTLD_NEXT )
147139 {
148- - HANDLE hCurrentProc;
149- + HANDLE hCurrentProc = 0;
150- HMODULE *modules;
151- DWORD cbNeeded;
152- DWORD dwSize;
153- @@ -588,6 +622,7 @@ void *dlsym( void *handle, const char *name )
140+ HANDLE hCurrentProc;
141+ @@ -588,6 +619,7 @@ void *dlsym( void *handle, const char *name )
154142 }
155143 }
156144 }
157145+ #endif
158146
159147 end:
160148 if( symbol == NULL )
161- - -
162- 2.53.0
163-
0 commit comments