diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..f6a2eb7 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +# dlfcn-win32 patches: keep exact bytes (prevents LF/CRLF munging) +depends/windows/dlfcn-win32/*.patch -text +depends/windowsstore/dlfcn-win32/*.patch -text diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 8a3b6b1..dad42de 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -37,6 +37,7 @@ jobs: ARCHITECTURE: x64 CONFIGURATION: Release WINSTORE: -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION="10.0.22621.0" + USE_PATCH_WRAPPER: 'true' workspace: clean: all @@ -53,12 +54,68 @@ jobs: echo $(app_id) . . > definition/$(app_id)/$(app_id).txt mklink /J "$(Pipeline.Workspace)/$(app_id)" "$(Build.SourcesDirectory)" + - powershell: | + $patchDir = 'C:\Strawberry\c\bin' + $patchExe = Join-Path $patchDir 'patch.exe' + $realExe = Join-Path $patchDir 'patch-real.exe' + $src = Join-Path $env:TEMP 'patch-wrapper.cs' + $out = Join-Path $patchDir 'patch.exe' + + if (-not (Test-Path $realExe)) { + Rename-Item $patchExe 'patch-real.exe' + } + + @' + using System; + using System.Diagnostics; + + class PatchWrapper + { + static int Main(string[] args) + { + var psi = new ProcessStartInfo(); + psi.FileName = @"C:\Strawberry\c\bin\patch-real.exe"; + psi.UseShellExecute = false; + + var quoted = new string[args.Length]; + for (int i = 0; i < args.Length; i++) + quoted[i] = "\"" + args[i].Replace("\"", "\\\"") + "\""; + + bool useBinary = false; + for (int i = 0; i < args.Length; i++) + { + if (args[i].IndexOf("dlfcn-win32", StringComparison.OrdinalIgnoreCase) >= 0) + { + useBinary = true; + break; + } + } + + psi.Arguments = + (useBinary ? "--binary " : "") + string.Join(" ", quoted); + + var p = Process.Start(psi); + p.WaitForExit(); + return p.ExitCode; + } + } + '@ | Set-Content $src -Encoding Ascii + + & "$env:WINDIR\Microsoft.NET\Framework64\v4.0.30319\csc.exe" ` + /nologo /target:exe /out:$out $src + displayName: "Replace Strawberry patch.exe with --binary wrapper" + condition: and(succeeded(), eq(variables['USE_PATCH_WRAPPER'], 'true')) + - task: CMake@1 + env: + PATHEXT: $(PATHEXT) inputs: workingDirectory: 'build' cmakeArgs: '-T host=x64 -G "$(GENERATOR)" -A $(ARCHITECTURE) $(WINSTORE) -DADDONS_TO_BUILD=$(app_id) -DCMAKE_BUILD_TYPE=$(CONFIGURATION) -DADDONS_DEFINITION_DIR=$(Pipeline.Workspace)/$(app_id)/build/definition -DADDON_SRC_PREFIX=../.. -DCMAKE_INSTALL_PREFIX=../../kodi/addons -DPACKAGE_ZIP=1 ../../kodi/cmake/addons' - task: CMake@1 + env: + PATHEXT: $(PATHEXT) inputs: workingDirectory: 'build' cmakeArgs: '--build . --config $(CONFIGURATION) --target $(app_id)' diff --git a/depends/windows/dlfcn-win32/0001-dlopen_with_widechar.patch b/depends/windows/dlfcn-win32/0001-dlopen_with_widechar.patch new file mode 100644 index 0000000..76d6f35 --- /dev/null +++ b/depends/windows/dlfcn-win32/0001-dlopen_with_widechar.patch @@ -0,0 +1,37 @@ +From 262365e15599077a3a69da43078f1f5193aa3061 Mon Sep 17 00:00:00 2001 +From: Garrett Brown +Date: Sun, 1 Mar 2026 00:15:29 -0800 +Subject: [PATCH] dlopen with widechar + +--- + src/dlfcn.c | 14 +++++++++++++- + 1 file changed, 13 insertions(+), 1 deletion(-) + +diff --git a/src/dlfcn.c b/src/dlfcn.c +index cb9f9bb..82e0c1e 100644 +--- a/src/dlfcn.c ++++ b/src/dlfcn.c +@@ -415,7 +415,19 @@ void *dlopen( const char *file, int mode ) + * to UNIX's search paths (start with system folders instead of current + * folder). + */ +- hModule = LoadLibraryExA( lpFileName, NULL, LOAD_WITH_ALTERED_SEARCH_PATH ); ++ int wide_len = MultiByteToWideChar(CP_UTF8, 0, lpFileName, -1, 0, 0); ++ if (wide_len > 0) ++ { ++ wchar_t* lpFileNameW = (wchar_t*)malloc(wide_len * sizeof(wchar_t)); ++ MultiByteToWideChar(CP_UTF8, 0, lpFileName, -1, lpFileNameW, wide_len); ++ ++ hModule = LoadLibraryExW(lpFileNameW, NULL, ++ LOAD_WITH_ALTERED_SEARCH_PATH ); ++ ++ free(lpFileNameW); ++ } ++ else ++ hModule = 0; + + if( !hModule ) + { +-- +2.52.0 + diff --git a/depends/windows/dlfcn-win32/dlfcn-win32.sha256 b/depends/windows/dlfcn-win32/dlfcn-win32.sha256 index d906474..4d789d7 100644 --- a/depends/windows/dlfcn-win32/dlfcn-win32.sha256 +++ b/depends/windows/dlfcn-win32/dlfcn-win32.sha256 @@ -1 +1 @@ -f18a412e84d8b701e61a78252411fe8c72587f52417c1ef21ca93604de1b9c55 +f61a874bc9163ab488accb364fd681d109870c86e8071f4710cbcdcbaf9f2565 diff --git a/depends/windows/dlfcn-win32/dlfcn-win32.txt b/depends/windows/dlfcn-win32/dlfcn-win32.txt index 6ef69af..e4993f7 100644 --- a/depends/windows/dlfcn-win32/dlfcn-win32.txt +++ b/depends/windows/dlfcn-win32/dlfcn-win32.txt @@ -1 +1 @@ -dlfcn-win32 https://github.com/dlfcn-win32/dlfcn-win32/archive/v1.2.0.tar.gz +dlfcn-win32 https://github.com/dlfcn-win32/dlfcn-win32/archive/v1.4.2.tar.gz diff --git a/depends/windowsstore/dlfcn-win32/0001-win10-fixed-uwp-build.patch b/depends/windowsstore/dlfcn-win32/0001-win10-fixed-uwp-build.patch index c8ac8dc..4e6e5a9 100644 --- a/depends/windowsstore/dlfcn-win32/0001-win10-fixed-uwp-build.patch +++ b/depends/windowsstore/dlfcn-win32/0001-win10-fixed-uwp-build.patch @@ -1,41 +1,42 @@ -From f85366b1044fff7b4ea9162c3edcd8278c3e06ff Mon Sep 17 00:00:00 2001 -From: Alwin Esch -Date: Thu, 22 Aug 2019 19:30:12 +0100 -Subject: [PATCH] [win10] fixed uwp build - ---- - dlfcn.c | 43 ++++++++++++++++++++++++++++++++++++++----- - 1 file changed, 38 insertions(+), 5 deletions(-) - -diff --git a/dlfcn.c b/dlfcn.c -index 69670d1..2d77ca8 100644 ---- a/dlfcn.c -+++ b/dlfcn.c -@@ -19,6 +19,7 @@ - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +From 4a4ba9ce9f666a66d027d84a26bb49bd6f92205a Mon Sep 17 00:00:00 2001 +From: Alwin Esch +Date: Thu, 22 Aug 2019 19:30:12 +0100 +Subject: [PATCH] [win10] fixed uwp build + +--- + src/dlfcn.c | 43 ++++++++++++++++++++++++++++++++++++++----- + 1 file changed, 38 insertions(+), 5 deletions(-) + +diff --git a/src/dlfcn.c b/src/dlfcn.c +index cb9f9bb..74cac34 100644 +--- a/src/dlfcn.c ++++ b/src/dlfcn.c +@@ -24,6 +24,7 @@ + * THE SOFTWARE. */ +#define _CRT_SECURE_NO_WARNINGS #ifdef _DEBUG #define _CRTDBG_MAP_ALLOC #include -@@ -193,6 +194,7 @@ static void save_err_ptr_str( const void *ptr ) +@@ -311,6 +312,7 @@ static HMODULE MyGetModuleHandleFromAddress( const void *addr ) /* Load Psapi.dll at runtime, this avoids linking caveat */ static BOOL MyEnumProcessModules( HANDLE hProcess, HMODULE *lphModule, DWORD cb, LPDWORD lpcbNeeded ) { +#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY != WINAPI_FAMILY_APP) - static BOOL (WINAPI *EnumProcessModulesPtr)(HANDLE, HMODULE *, DWORD, LPDWORD); - HMODULE psapi; - -@@ -206,20 +208,26 @@ static BOOL MyEnumProcessModules( HANDLE hProcess, HMODULE *lphModule, DWORD cb, + static BOOL (WINAPI *EnumProcessModulesPtr)(HANDLE, HMODULE *, DWORD, LPDWORD) = NULL; + static BOOL failed = FALSE; + UINT uMode; +@@ -349,21 +351,27 @@ static BOOL MyEnumProcessModules( HANDLE hProcess, HMODULE *lphModule, DWORD cb, } return EnumProcessModulesPtr( hProcess, lphModule, cb, lpcbNeeded ); +#else -+ return 0; ++ return 0; +#endif } + DLFCN_EXPORT void *dlopen( const char *file, int mode ) { - HMODULE hModule; @@ -43,102 +44,99 @@ index 69670d1..2d77ca8 100644 + HMODULE hModule = NULL; + UINT uMode = 0; - current_error = NULL; + error_occurred = FALSE; /* Do not let Windows display the critical-error-handler message box */ +#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY != WINAPI_FAMILY_APP) - uMode = SetErrorMode( SEM_FAILCRITICALERRORS ); + uMode = MySetErrorMode( SEM_FAILCRITICALERRORS ); +#endif - if( file == 0 ) + if( file == NULL ) { +#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY != WINAPI_FAMILY_APP) // what is replacement of GMH on UWP? - /* POSIX says that if the value of file is 0, a handle on a global + /* POSIX says that if the value of file is NULL, a handle on a global * symbol object must be provided. That object must be able to access * all symbols from the original program file, and any objects loaded -@@ -234,6 +242,7 @@ void *dlopen( const char *file, int mode ) +@@ -378,6 +386,7 @@ void *dlopen( const char *file, int mode ) if( !hModule ) - save_err_ptr_str( file ); + save_err_str( "(null)", GetLastError( ) ); +#endif } else { -@@ -264,11 +273,29 @@ void *dlopen( const char *file, int mode ) - * to UNIX's search paths (start with system folders instead of current - * folder). - */ +@@ -415,8 +424,25 @@ void *dlopen( const char *file, int mode ) + * to UNIX's search paths (start with system folders instead of current + * folder). + */ +- hModule = LoadLibraryExA( lpFileName, NULL, LOAD_WITH_ALTERED_SEARCH_PATH ); +#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) -+ int result = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, lpFileName, strlen(lpFileName), NULL, 0); -+ if (result == 0) -+ return NULL; -+ -+ wchar_t* newStr = (wchar_t*)malloc(result*sizeof(wchar_t)); -+ result = MultiByteToWideChar( CP_UTF8, MB_ERR_INVALID_CHARS, lpFileName, strlen(lpFileName), newStr, result ); -+ if (result == 0) -+ { -+ free( newStr ); -+ return NULL; -+ } ++ int result = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, lpFileName, strlen(lpFileName), NULL, 0); ++ if (result == 0) ++ return NULL; + -+ hModule = LoadPackagedLibrary( newStr, 0 ); -+ free( newStr ); -+ dwProcModsAfter = 0; ++ wchar_t* newStr = (wchar_t*)malloc(result*sizeof(wchar_t)); ++ result = MultiByteToWideChar( CP_UTF8, MB_ERR_INVALID_CHARS, lpFileName, strlen(lpFileName), newStr, result ); ++ if (result == 0) ++ { ++ free( newStr ); ++ return NULL; ++ } + ++ hModule = LoadPackagedLibrary( newStr, 0 ); ++ free( newStr ); ++ dwProcModsAfter = 0; +#else // WINAPI_PARTITION_DESKTOP - hModule = LoadLibraryExA(lpFileName, NULL, - LOAD_WITH_ALTERED_SEARCH_PATH ); - - if( MyEnumProcessModules( hCurrentProc, NULL, 0, &dwProcModsAfter ) == 0 ) - dwProcModsAfter = 0; ++ hModule = LoadLibraryExA( lpFileName, NULL, LOAD_WITH_ALTERED_SEARCH_PATH ); +#endif - - /* If the object was loaded with RTLD_LOCAL, add it to list of local - * objects, so that its symbols cannot be retrieved even if the handle for -@@ -288,7 +315,9 @@ void *dlopen( const char *file, int mode ) + if( !hModule ) + { + save_err_str( lpFileName, GetLastError( ) ); +@@ -453,7 +479,9 @@ void *dlopen( const char *file, int mode ) } /* Return to previous state of the error-mode bit flags. */ +#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY != WINAPI_FAMILY_APP) - SetErrorMode( uMode ); + MySetErrorMode( uMode ); +#endif return (void *) hModule; } -@@ -321,12 +350,14 @@ void *dlsym( void *handle, const char *name ) +@@ -488,13 +516,15 @@ void *dlsym( void *handle, const char *name ) { FARPROC symbol; HMODULE hCaller; - HMODULE hModule; -- HANDLE hCurrentProc; +- DWORD dwMessageId; + HMODULE hModule = 0; -+ HANDLE hCurrentProc = 0; ++ DWORD dwMessageId = 0; + + error_occurred = FALSE; - current_error = NULL; symbol = NULL; hCaller = NULL; + +#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY != WINAPI_FAMILY_APP) // what is replacement of GMH on UWP? hModule = GetModuleHandle( NULL ); - hCurrentProc = GetCurrentProcess( ); + dwMessageId = 0; -@@ -358,6 +389,7 @@ void *dlsym( void *handle, const char *name ) - if(!hCaller) +@@ -525,6 +555,7 @@ void *dlsym( void *handle, const char *name ) goto end; + } } +#endif if( handle != RTLD_NEXT ) { -@@ -370,7 +402,7 @@ void *dlsym( void *handle, const char *name ) - /* If the handle for the original program file is passed, also search +@@ -538,6 +569,7 @@ void *dlsym( void *handle, const char *name ) * in all globally loaded objects. */ -- + +#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY != WINAPI_FAMILY_APP) if( hModule == handle || handle == RTLD_NEXT ) { - HMODULE *modules; -@@ -410,6 +442,7 @@ void *dlsym( void *handle, const char *name ) + HANDLE hCurrentProc; +@@ -588,6 +620,7 @@ void *dlsym( void *handle, const char *name ) } } } @@ -146,6 +144,6 @@ index 69670d1..2d77ca8 100644 end: if( symbol == NULL ) --- -2.19.2.windows.1 - +-- +2.47.1.windows.1 + diff --git a/depends/windowsstore/dlfcn-win32/dlfcn-win32.sha256 b/depends/windowsstore/dlfcn-win32/dlfcn-win32.sha256 index d906474..4d789d7 100644 --- a/depends/windowsstore/dlfcn-win32/dlfcn-win32.sha256 +++ b/depends/windowsstore/dlfcn-win32/dlfcn-win32.sha256 @@ -1 +1 @@ -f18a412e84d8b701e61a78252411fe8c72587f52417c1ef21ca93604de1b9c55 +f61a874bc9163ab488accb364fd681d109870c86e8071f4710cbcdcbaf9f2565 diff --git a/depends/windowsstore/dlfcn-win32/dlfcn-win32.txt b/depends/windowsstore/dlfcn-win32/dlfcn-win32.txt index 6ef69af..e4993f7 100644 --- a/depends/windowsstore/dlfcn-win32/dlfcn-win32.txt +++ b/depends/windowsstore/dlfcn-win32/dlfcn-win32.txt @@ -1 +1 @@ -dlfcn-win32 https://github.com/dlfcn-win32/dlfcn-win32/archive/v1.2.0.tar.gz +dlfcn-win32 https://github.com/dlfcn-win32/dlfcn-win32/archive/v1.4.2.tar.gz