Skip to content

Commit 6e172f0

Browse files
authored
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.
1 parent 018e7f5 commit 6e172f0

File tree

4 files changed

+4
-40
lines changed

4 files changed

+4
-40
lines changed

win32/build/confutils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3426,7 +3426,7 @@ function toolset_setup_common_ldlags()
34263426
function toolset_setup_common_libs()
34273427
{
34283428
// urlmon.lib ole32.lib oleaut32.lib uuid.lib gdi32.lib winspool.lib comdlg32.lib
3429-
DEFINE("LIBS", "kernel32.lib ole32.lib user32.lib advapi32.lib shell32.lib ws2_32.lib Dnsapi.lib psapi.lib bcrypt.lib");
3429+
DEFINE("LIBS", "kernel32.lib ole32.lib user32.lib advapi32.lib shell32.lib ws2_32.lib Dnsapi.lib psapi.lib bcrypt.lib Pathcch.lib");
34303430
}
34313431

34323432
function toolset_setup_build_mode()

win32/dllmain.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include <config.w32.h>
1818

1919
#include <php.h>
20-
#include <win32/ioutil.h>
2120

2221
#ifdef HAVE_LIBXML
2322
#include <libxml/threads.h>
@@ -34,16 +33,11 @@ BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, LPVOID dummy)
3433
{
3534
BOOL ret = TRUE;
3635

36+
#if 0 /* prepared */
3737
switch (reason)
3838
{
3939
case DLL_PROCESS_ATTACH:
40-
ret = ret && php_win32_ioutil_init();
41-
if (!ret) {
42-
fprintf(stderr, "ioutil initialization failed");
43-
return ret;
44-
}
4540
break;
46-
#if 0 /* prepared */
4741
case DLL_PROCESS_DETACH:
4842
/* pass */
4943
break;
@@ -55,8 +49,8 @@ BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, LPVOID dummy)
5549
case DLL_THREAD_DETACH:
5650
/* pass */
5751
break;
58-
#endif
5952
}
53+
#endif
6054

6155
#ifdef HAVE_LIBXML
6256
/* This imply that only LIBXML_STATIC_FOR_DLL is supported ATM.

win32/ioutil.c

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@
6767
#include <winnls.h>
6868
*/
6969

70-
typedef HRESULT (__stdcall *MyPathCchCanonicalizeEx)(wchar_t *pszPathOut, size_t cchPathOut, const wchar_t *pszPathIn, unsigned long dwFlags);
71-
72-
static MyPathCchCanonicalizeEx canonicalize_path_w = NULL;
73-
7470
PW32IO BOOL php_win32_ioutil_posix_to_open_opts(int flags, mode_t mode, php_ioutil_open_opts *opts)
7571
{/*{{{*/
7672
int current_umask;
@@ -619,7 +615,7 @@ PW32IO php_win32_ioutil_normalization_result php_win32_ioutil_normalize_path_w(w
619615
}
620616
}
621617

622-
if (S_OK != canonicalize_path_w(canonicalw, MAXPATHLEN, _tmp, PATHCCH_ALLOW_LONG_PATHS)) {
618+
if (S_OK != PathCchCanonicalizeEx(canonicalw, MAXPATHLEN, _tmp, PATHCCH_ALLOW_LONG_PATHS)) {
623619
/* Length unchanged. */
624620
*new_len = len;
625621
return PHP_WIN32_IOUTIL_NORM_PARTIAL;
@@ -643,27 +639,6 @@ PW32IO php_win32_ioutil_normalization_result php_win32_ioutil_normalize_path_w(w
643639
return PHP_WIN32_IOUTIL_NORM_OK;
644640
}/*}}}*/
645641

646-
static HRESULT __stdcall MyPathCchCanonicalizeExFallback(wchar_t *pszPathOut, size_t cchPathOut, const wchar_t *pszPathIn, unsigned long dwFlags)
647-
{/*{{{*/
648-
return -42;
649-
}/*}}}*/
650-
651-
BOOL php_win32_ioutil_init(void)
652-
{/*{{{*/
653-
HMODULE hMod = GetModuleHandle("api-ms-win-core-path-l1-1-0");
654-
655-
if (hMod) {
656-
canonicalize_path_w = (MyPathCchCanonicalizeEx)GetProcAddress(hMod, "PathCchCanonicalizeEx");
657-
if (!canonicalize_path_w) {
658-
canonicalize_path_w = (MyPathCchCanonicalizeEx)MyPathCchCanonicalizeExFallback;
659-
}
660-
} else {
661-
canonicalize_path_w = (MyPathCchCanonicalizeEx)MyPathCchCanonicalizeExFallback;
662-
}
663-
664-
return TRUE;
665-
}/*}}}*/
666-
667642
PW32IO int php_win32_ioutil_access_w(const wchar_t *path, mode_t mode)
668643
{/*{{{*/
669644
DWORD attr;

win32/ioutil.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,6 @@ typedef enum {
169169
} while (0);
170170

171171
PW32IO php_win32_ioutil_normalization_result php_win32_ioutil_normalize_path_w(wchar_t **buf, size_t len, size_t *new_len);
172-
#ifdef PHP_EXPORTS
173-
/* This symbols are needed only for the DllMain, but should not be exported
174-
or be available when used with PHP binaries. */
175-
BOOL php_win32_ioutil_init(void);
176-
#endif
177172

178173
/* Keep these functions aliased for case some additional handling
179174
is needed later. */

0 commit comments

Comments
 (0)