1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Drop fallback for PathCchCanonicalizeEx() (GH-16341)

This function is only available as of Windows 8 and Windows Server 2012,
respectively, and thus needed a fallback (albeit a non working one).
However, as of PHP 8.3.0 Windows 8/Server 2012 is required anyway, so
we can drop the fallback as well as the dynamic loading in favor of
linking to the import library.
This commit is contained in:
Christoph M. Becker
2024-10-11 00:03:37 +02:00
committed by GitHub
parent 018e7f5842
commit 6e172f0ac1
4 changed files with 4 additions and 40 deletions

View File

@@ -3426,7 +3426,7 @@ function toolset_setup_common_ldlags()
function toolset_setup_common_libs()
{
// urlmon.lib ole32.lib oleaut32.lib uuid.lib gdi32.lib winspool.lib comdlg32.lib
DEFINE("LIBS", "kernel32.lib ole32.lib user32.lib advapi32.lib shell32.lib ws2_32.lib Dnsapi.lib psapi.lib bcrypt.lib");
DEFINE("LIBS", "kernel32.lib ole32.lib user32.lib advapi32.lib shell32.lib ws2_32.lib Dnsapi.lib psapi.lib bcrypt.lib Pathcch.lib");
}
function toolset_setup_build_mode()

View File

@@ -17,7 +17,6 @@
#include <config.w32.h>
#include <php.h>
#include <win32/ioutil.h>
#ifdef HAVE_LIBXML
#include <libxml/threads.h>
@@ -34,16 +33,11 @@ BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, LPVOID dummy)
{
BOOL ret = TRUE;
#if 0 /* prepared */
switch (reason)
{
case DLL_PROCESS_ATTACH:
ret = ret && php_win32_ioutil_init();
if (!ret) {
fprintf(stderr, "ioutil initialization failed");
return ret;
}
break;
#if 0 /* prepared */
case DLL_PROCESS_DETACH:
/* pass */
break;
@@ -55,8 +49,8 @@ BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, LPVOID dummy)
case DLL_THREAD_DETACH:
/* pass */
break;
#endif
}
#endif
#ifdef HAVE_LIBXML
/* This imply that only LIBXML_STATIC_FOR_DLL is supported ATM.

View File

@@ -67,10 +67,6 @@
#include <winnls.h>
*/
typedef HRESULT (__stdcall *MyPathCchCanonicalizeEx)(wchar_t *pszPathOut, size_t cchPathOut, const wchar_t *pszPathIn, unsigned long dwFlags);
static MyPathCchCanonicalizeEx canonicalize_path_w = NULL;
PW32IO BOOL php_win32_ioutil_posix_to_open_opts(int flags, mode_t mode, php_ioutil_open_opts *opts)
{/*{{{*/
int current_umask;
@@ -619,7 +615,7 @@ PW32IO php_win32_ioutil_normalization_result php_win32_ioutil_normalize_path_w(w
}
}
if (S_OK != canonicalize_path_w(canonicalw, MAXPATHLEN, _tmp, PATHCCH_ALLOW_LONG_PATHS)) {
if (S_OK != PathCchCanonicalizeEx(canonicalw, MAXPATHLEN, _tmp, PATHCCH_ALLOW_LONG_PATHS)) {
/* Length unchanged. */
*new_len = len;
return PHP_WIN32_IOUTIL_NORM_PARTIAL;
@@ -643,27 +639,6 @@ PW32IO php_win32_ioutil_normalization_result php_win32_ioutil_normalize_path_w(w
return PHP_WIN32_IOUTIL_NORM_OK;
}/*}}}*/
static HRESULT __stdcall MyPathCchCanonicalizeExFallback(wchar_t *pszPathOut, size_t cchPathOut, const wchar_t *pszPathIn, unsigned long dwFlags)
{/*{{{*/
return -42;
}/*}}}*/
BOOL php_win32_ioutil_init(void)
{/*{{{*/
HMODULE hMod = GetModuleHandle("api-ms-win-core-path-l1-1-0");
if (hMod) {
canonicalize_path_w = (MyPathCchCanonicalizeEx)GetProcAddress(hMod, "PathCchCanonicalizeEx");
if (!canonicalize_path_w) {
canonicalize_path_w = (MyPathCchCanonicalizeEx)MyPathCchCanonicalizeExFallback;
}
} else {
canonicalize_path_w = (MyPathCchCanonicalizeEx)MyPathCchCanonicalizeExFallback;
}
return TRUE;
}/*}}}*/
PW32IO int php_win32_ioutil_access_w(const wchar_t *path, mode_t mode)
{/*{{{*/
DWORD attr;

View File

@@ -169,11 +169,6 @@ typedef enum {
} while (0);
PW32IO php_win32_ioutil_normalization_result php_win32_ioutil_normalize_path_w(wchar_t **buf, size_t len, size_t *new_len);
#ifdef PHP_EXPORTS
/* This symbols are needed only for the DllMain, but should not be exported
or be available when used with PHP binaries. */
BOOL php_win32_ioutil_init(void);
#endif
/* Keep these functions aliased for case some additional handling
is needed later. */