Skip to content

Drop fallback for PathCchCanonicalizeEx() #16341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion win32/build/confutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 2 additions & 8 deletions win32/dllmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include <config.w32.h>

#include <php.h>
#include <win32/ioutil.h>

#ifdef HAVE_LIBXML
#include <libxml/threads.h>
Expand All @@ -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;
Expand All @@ -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.
Expand Down
27 changes: 1 addition & 26 deletions win32/ioutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
5 changes: 0 additions & 5 deletions win32/ioutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
Loading