1*c34c9f81SPeterdiff -ruN misc/Python-3.11.15/PC/aoo_win7_compat.h misc/build/Python-3.11.15/PC/aoo_win7_compat.h 2*c34c9f81SPeter--- misc/Python-3.11.15/PC/aoo_win7_compat.h 1970-01-01 00:00:00.000000000 +0000 3*c34c9f81SPeter+++ misc/build/Python-3.11.15/PC/aoo_win7_compat.h 2025-01-01 00:00:00.000000000 +0000 4*c34c9f81SPeter@@ -0,0 +1,48 @@ 5*c34c9f81SPeter+/* 6*c34c9f81SPeter+ * Licensed to the Apache Software Foundation (ASF) under one 7*c34c9f81SPeter+ * or more contributor license agreements. See the NOTICE file 8*c34c9f81SPeter+ * distributed with this work for additional information 9*c34c9f81SPeter+ * regarding copyright ownership. The ASF licenses this file 10*c34c9f81SPeter+ * to you under the Apache License, Version 2.0 (the 11*c34c9f81SPeter+ * "License"); you may not use this file except in compliance 12*c34c9f81SPeter+ * with the License. You may obtain a copy of the License at 13*c34c9f81SPeter+ * 14*c34c9f81SPeter+ * http://www.apache.org/licenses/LICENSE-2.0 15*c34c9f81SPeter+ * 16*c34c9f81SPeter+ * Unless required by applicable law or agreed to in writing, 17*c34c9f81SPeter+ * software distributed under the License is distributed on an 18*c34c9f81SPeter+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 19*c34c9f81SPeter+ * KIND, either express or implied. See the License for the 20*c34c9f81SPeter+ * specific language governing permissions and limitations 21*c34c9f81SPeter+ * under the License. 22*c34c9f81SPeter+ */ 23*c34c9f81SPeter+ 24*c34c9f81SPeter+/* 25*c34c9f81SPeter+ * Force-included into every CPython translation unit (PCbuild/pyproject.props, 26*c34c9f81SPeter+ * ForcedIncludeFiles). 27*c34c9f81SPeter+ * 28*c34c9f81SPeter+ * CPython 3.11 is compiled here at the Windows 7 API level (Py_WINVER 0x0601 29*c34c9f81SPeter+ * in PC/pyconfig.h) instead of upstream's Windows 8 one, so the SDK hides what it 30*c34c9f81SPeter+ * gates on Windows 8. Most of that would be a real dependency and must stay a 31*c34c9f81SPeter+ * compile error. What is defined here is only what CPython uses WITHOUT 32*c34c9f81SPeter+ * depending on Windows 8 -- plain constants, never functions -- each with the 33*c34c9f81SPeter+ * use that makes it safe. The values are the SDK's. 34*c34c9f81SPeter+ * 35*c34c9f81SPeter+ * Found by matching every name the 10.0.19041.0 SDK declares under a Windows 8 36*c34c9f81SPeter+ * or later guard against the sources this module compiles. 37*c34c9f81SPeter+ */ 38*c34c9f81SPeter+ 39*c34c9f81SPeter+#ifndef AOO_PYTHON_WIN7_COMPAT_H 40*c34c9f81SPeter+#define AOO_PYTHON_WIN7_COMPAT_H 41*c34c9f81SPeter+ 42*c34c9f81SPeter+/* WinNls.h, WINVER >= _WIN32_WINNT_WIN8. Modules/_winapi.c 43*c34c9f81SPeter+ (_winapi.LCMapStringEx) only uses them to reject these flags with 44*c34c9f81SPeter+ ValueError before calling LCMapStringEx, which itself exists from Vista. */ 45*c34c9f81SPeter+#ifndef LCMAP_SORTHANDLE 46*c34c9f81SPeter+#define LCMAP_SORTHANDLE 0x20000000 47*c34c9f81SPeter+#endif 48*c34c9f81SPeter+#ifndef LCMAP_HASH 49*c34c9f81SPeter+#define LCMAP_HASH 0x00040000 50*c34c9f81SPeter+#endif 51*c34c9f81SPeter+ 52*c34c9f81SPeter+#endif /* AOO_PYTHON_WIN7_COMPAT_H */ 53*c34c9f81SPeterdiff -ruN misc/Python-3.11.15/PC/pathcch.h misc/build/Python-3.11.15/PC/pathcch.h 54*c34c9f81SPeter--- misc/Python-3.11.15/PC/pathcch.h 1970-01-01 00:00:00.000000000 +0000 55*c34c9f81SPeter+++ misc/build/Python-3.11.15/PC/pathcch.h 2025-01-01 00:00:00.000000000 +0000 56*c34c9f81SPeter@@ -0,0 +1,63 @@ 57*c34c9f81SPeter+/* 58*c34c9f81SPeter+ * Licensed to the Apache Software Foundation (ASF) under one 59*c34c9f81SPeter+ * or more contributor license agreements. See the NOTICE file 60*c34c9f81SPeter+ * distributed with this work for additional information 61*c34c9f81SPeter+ * regarding copyright ownership. The ASF licenses this file 62*c34c9f81SPeter+ * to you under the Apache License, Version 2.0 (the 63*c34c9f81SPeter+ * "License"); you may not use this file except in compliance 64*c34c9f81SPeter+ * with the License. You may obtain a copy of the License at 65*c34c9f81SPeter+ * 66*c34c9f81SPeter+ * http://www.apache.org/licenses/LICENSE-2.0 67*c34c9f81SPeter+ * 68*c34c9f81SPeter+ * Unless required by applicable law or agreed to in writing, 69*c34c9f81SPeter+ * software distributed under the License is distributed on an 70*c34c9f81SPeter+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 71*c34c9f81SPeter+ * KIND, either express or implied. See the License for the 72*c34c9f81SPeter+ * specific language governing permissions and limitations 73*c34c9f81SPeter+ * under the License. 74*c34c9f81SPeter+ */ 75*c34c9f81SPeter+ 76*c34c9f81SPeter+/* 77*c34c9f81SPeter+ * Stand-in for the Windows SDK's <pathcch.h>, for a Python that must load on 78*c34c9f81SPeter+ * Windows 7 SP1. 79*c34c9f81SPeter+ * 80*c34c9f81SPeter+ * The SDK header declares the PathCch* functions as imports from 81*c34c9f81SPeter+ * api-ms-win-core-path-l1-1-0.dll, an API set that exists from Windows 8 on. 82*c34c9f81SPeter+ * A python311.dll importing it statically cannot be loaded on Windows 7 at 83*c34c9f81SPeter+ * all. This file lives in PC/, which is on the include path ahead of the SDK, 84*c34c9f81SPeter+ * so `#include <pathcch.h>` in getpath.c, posixmodule.c, fileutils.c and 85*c34c9f81SPeter+ * pathconfig.c resolves here instead and the SDK header is never seen. 86*c34c9f81SPeter+ * 87*c34c9f81SPeter+ * Only what those four files use is declared. The definitions in 88*c34c9f81SPeter+ * PC/pathcch_win7.c call the real functions from KernelBase.dll when it 89*c34c9f81SPeter+ * exports them (Windows 8 and later), so behaviour there is the system's own; 90*c34c9f81SPeter+ * the fallbacks only ever run on Windows 7. 91*c34c9f81SPeter+ */ 92*c34c9f81SPeter+ 93*c34c9f81SPeter+#ifndef AOO_PYTHON_PATHCCH_H 94*c34c9f81SPeter+#define AOO_PYTHON_PATHCCH_H 95*c34c9f81SPeter+ 96*c34c9f81SPeter+#include <windows.h> 97*c34c9f81SPeter+ 98*c34c9f81SPeter+#ifdef __cplusplus 99*c34c9f81SPeter+extern "C" { 100*c34c9f81SPeter+#endif 101*c34c9f81SPeter+ 102*c34c9f81SPeter+#define PATHCCH_NONE 0x00000000 103*c34c9f81SPeter+#define PATHCCH_ALLOW_LONG_PATHS 0x00000001 104*c34c9f81SPeter+ 105*c34c9f81SPeter+/* Largest buffer, in characters, the PathCch functions accept. */ 106*c34c9f81SPeter+#define PATHCCH_MAX_CCH 0x8000 107*c34c9f81SPeter+ 108*c34c9f81SPeter+HRESULT WINAPI PathCchSkipRoot(PCWSTR pszPath, PCWSTR *ppszRootEnd); 109*c34c9f81SPeter+HRESULT WINAPI PathCchFindExtension(PCWSTR pszPath, size_t cchPath, 110*c34c9f81SPeter+ PCWSTR *ppszExt); 111*c34c9f81SPeter+HRESULT WINAPI PathCchCombineEx(PWSTR pszPathOut, size_t cchPathOut, 112*c34c9f81SPeter+ PCWSTR pszPathIn, PCWSTR pszMore, 113*c34c9f81SPeter+ ULONG dwFlags); 114*c34c9f81SPeter+ 115*c34c9f81SPeter+#ifdef __cplusplus 116*c34c9f81SPeter+} 117*c34c9f81SPeter+#endif 118*c34c9f81SPeter+ 119*c34c9f81SPeter+#endif /* AOO_PYTHON_PATHCCH_H */ 120*c34c9f81SPeterdiff -ruN misc/Python-3.11.15/PC/pathcch_win7.c misc/build/Python-3.11.15/PC/pathcch_win7.c 121*c34c9f81SPeter--- misc/Python-3.11.15/PC/pathcch_win7.c 1970-01-01 00:00:00.000000000 +0000 122*c34c9f81SPeter+++ misc/build/Python-3.11.15/PC/pathcch_win7.c 2025-01-01 00:00:00.000000000 +0000 123*c34c9f81SPeter@@ -0,0 +1,241 @@ 124*c34c9f81SPeter+/* 125*c34c9f81SPeter+ * Licensed to the Apache Software Foundation (ASF) under one 126*c34c9f81SPeter+ * or more contributor license agreements. See the NOTICE file 127*c34c9f81SPeter+ * distributed with this work for additional information 128*c34c9f81SPeter+ * regarding copyright ownership. The ASF licenses this file 129*c34c9f81SPeter+ * to you under the Apache License, Version 2.0 (the 130*c34c9f81SPeter+ * "License"); you may not use this file except in compliance 131*c34c9f81SPeter+ * with the License. You may obtain a copy of the License at 132*c34c9f81SPeter+ * 133*c34c9f81SPeter+ * http://www.apache.org/licenses/LICENSE-2.0 134*c34c9f81SPeter+ * 135*c34c9f81SPeter+ * Unless required by applicable law or agreed to in writing, 136*c34c9f81SPeter+ * software distributed under the License is distributed on an 137*c34c9f81SPeter+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 138*c34c9f81SPeter+ * KIND, either express or implied. See the License for the 139*c34c9f81SPeter+ * specific language governing permissions and limitations 140*c34c9f81SPeter+ * under the License. 141*c34c9f81SPeter+ */ 142*c34c9f81SPeter+ 143*c34c9f81SPeter+/* 144*c34c9f81SPeter+ * PathCch* for a python311.dll that must load on Windows 7 SP1. See 145*c34c9f81SPeter+ * PC/pathcch.h for why this exists. 146*c34c9f81SPeter+ * 147*c34c9f81SPeter+ * Each function first asks KernelBase.dll for the real implementation. 148*c34c9f81SPeter+ * KernelBase is mapped into every process from Windows 7 on, so this loads 149*c34c9f81SPeter+ * nothing and searches no directory; from Windows 8 on it exports the PathCch 150*c34c9f81SPeter+ * family and the system's own code runs. Only when the export is missing -- 151*c34c9f81SPeter+ * i.e. on Windows 7 -- does the fallback below run. 152*c34c9f81SPeter+ * 153*c34c9f81SPeter+ * The fallbacks are written from the documented contract of each function, 154*c34c9f81SPeter+ * and cover what Python 3.11 asks of them: 155*c34c9f81SPeter+ * PathCchSkipRoot os._path_splitroot (posixmodule.c), _Py_isabs 156*c34c9f81SPeter+ * (fileutils.c) 157*c34c9f81SPeter+ * PathCchFindExtension the ".exe" test in getpath.c's isxfile 158*c34c9f81SPeter+ * PathCchCombineEx _Py_join_relfile (fileutils.c), used by getpath 159*c34c9f81SPeter+ * PathCchCombineEx falls back to shlwapi's PathCombineW and so is limited to 160*c34c9f81SPeter+ * MAX_PATH there -- which is the limit Windows 7 itself imposes on the Win32 161*c34c9f81SPeter+ * file API without a \\?\ prefix. 162*c34c9f81SPeter+ */ 163*c34c9f81SPeter+ 164*c34c9f81SPeter+#include "pathcch.h" 165*c34c9f81SPeter+ 166*c34c9f81SPeter+#include <shlwapi.h> 167*c34c9f81SPeter+#include <string.h> 168*c34c9f81SPeter+#include <wchar.h> 169*c34c9f81SPeter+ 170*c34c9f81SPeter+typedef HRESULT (WINAPI *skip_root_fn)(PCWSTR, PCWSTR *); 171*c34c9f81SPeter+typedef HRESULT (WINAPI *find_extension_fn)(PCWSTR, size_t, PCWSTR *); 172*c34c9f81SPeter+typedef HRESULT (WINAPI *combine_ex_fn)(PWSTR, size_t, PCWSTR, PCWSTR, ULONG); 173*c34c9f81SPeter+ 174*c34c9f81SPeter+/* Looks NAME up in KernelBase.dll once and remembers the answer in *SLOT: 175*c34c9f81SPeter+ 0 = not looked up yet, -1 = not exported, otherwise the address. Two 176*c34c9f81SPeter+ threads racing here store the same value, and a pointer-sized aligned store 177*c34c9f81SPeter+ is atomic on every Windows target, so no lock is needed. */ 178*c34c9f81SPeter+static FARPROC 179*c34c9f81SPeter+kernelbase_export(volatile LONG_PTR *slot, const char *name) 180*c34c9f81SPeter+{ 181*c34c9f81SPeter+ LONG_PTR value = *slot; 182*c34c9f81SPeter+ if (value == 0) { 183*c34c9f81SPeter+ HMODULE kernelbase = GetModuleHandleW(L"kernelbase.dll"); 184*c34c9f81SPeter+ FARPROC proc = kernelbase ? GetProcAddress(kernelbase, name) : NULL; 185*c34c9f81SPeter+ value = proc ? (LONG_PTR)proc : (LONG_PTR)-1; 186*c34c9f81SPeter+ *slot = value; 187*c34c9f81SPeter+ } 188*c34c9f81SPeter+ return value == (LONG_PTR)-1 ? NULL : (FARPROC)value; 189*c34c9f81SPeter+} 190*c34c9f81SPeter+ 191*c34c9f81SPeter+/* Advances past one path segment and the backslash ending it, if any. */ 192*c34c9f81SPeter+static PCWSTR 193*c34c9f81SPeter+skip_segment(PCWSTR p) 194*c34c9f81SPeter+{ 195*c34c9f81SPeter+ while (*p != L'\0' && *p != L'\\') { 196*c34c9f81SPeter+ ++p; 197*c34c9f81SPeter+ } 198*c34c9f81SPeter+ if (*p == L'\\') { 199*c34c9f81SPeter+ ++p; 200*c34c9f81SPeter+ } 201*c34c9f81SPeter+ return p; 202*c34c9f81SPeter+} 203*c34c9f81SPeter+ 204*c34c9f81SPeter+static int 205*c34c9f81SPeter+is_drive_letter(WCHAR c) 206*c34c9f81SPeter+{ 207*c34c9f81SPeter+ return (c >= L'A' && c <= L'Z') || (c >= L'a' && c <= L'z'); 208*c34c9f81SPeter+} 209*c34c9f81SPeter+ 210*c34c9f81SPeter+/* "X:" or "X:\" -> the character after it. */ 211*c34c9f81SPeter+static PCWSTR 212*c34c9f81SPeter+skip_drive(PCWSTR p) 213*c34c9f81SPeter+{ 214*c34c9f81SPeter+ p += 2; 215*c34c9f81SPeter+ if (*p == L'\\') { 216*c34c9f81SPeter+ ++p; 217*c34c9f81SPeter+ } 218*c34c9f81SPeter+ return p; 219*c34c9f81SPeter+} 220*c34c9f81SPeter+ 221*c34c9f81SPeter+/* Root forms, as documented for PathCchSkipRoot: 222*c34c9f81SPeter+ C:\path drive-absolute root "C:\" 223*c34c9f81SPeter+ C:path drive-relative root "C:" 224*c34c9f81SPeter+ \path rooted root "\" 225*c34c9f81SPeter+ \\server\share\path root "\\server\share\" 226*c34c9f81SPeter+ \\?\C:\path root "\\?\C:\" 227*c34c9f81SPeter+ \\?\UNC\server\share\path root "\\?\UNC\server\share\" 228*c34c9f81SPeter+ \\?\Volume{guid}\path root "\\?\Volume{guid}\" 229*c34c9f81SPeter+ Anything else -- a relative path -- has no root and is E_INVALIDARG. */ 230*c34c9f81SPeter+static HRESULT 231*c34c9f81SPeter+skip_root_fallback(PCWSTR path, PCWSTR *root_end) 232*c34c9f81SPeter+{ 233*c34c9f81SPeter+ PCWSTR p; 234*c34c9f81SPeter+ 235*c34c9f81SPeter+ if (path == NULL || root_end == NULL || path[0] == L'\0') { 236*c34c9f81SPeter+ return E_INVALIDARG; 237*c34c9f81SPeter+ } 238*c34c9f81SPeter+ *root_end = NULL; 239*c34c9f81SPeter+ 240*c34c9f81SPeter+ if (path[0] == L'\\' && path[1] == L'\\') { 241*c34c9f81SPeter+ if (path[2] == L'?') { 242*c34c9f81SPeter+ if (path[3] != L'\\') { 243*c34c9f81SPeter+ return E_INVALIDARG; 244*c34c9f81SPeter+ } 245*c34c9f81SPeter+ p = path + 4; 246*c34c9f81SPeter+ if (_wcsnicmp(p, L"UNC\\", 4) == 0) { 247*c34c9f81SPeter+ p = skip_segment(p + 4); /* server */ 248*c34c9f81SPeter+ p = skip_segment(p); /* share */ 249*c34c9f81SPeter+ } 250*c34c9f81SPeter+ else if (is_drive_letter(p[0]) && p[1] == L':') { 251*c34c9f81SPeter+ p = skip_drive(p); 252*c34c9f81SPeter+ } 253*c34c9f81SPeter+ else if (_wcsnicmp(p, L"Volume{", 7) == 0) { 254*c34c9f81SPeter+ p = skip_segment(p); 255*c34c9f81SPeter+ } 256*c34c9f81SPeter+ else { 257*c34c9f81SPeter+ return E_INVALIDARG; 258*c34c9f81SPeter+ } 259*c34c9f81SPeter+ } 260*c34c9f81SPeter+ else { 261*c34c9f81SPeter+ p = skip_segment(path + 2); /* server */ 262*c34c9f81SPeter+ p = skip_segment(p); /* share */ 263*c34c9f81SPeter+ } 264*c34c9f81SPeter+ } 265*c34c9f81SPeter+ else if (is_drive_letter(path[0]) && path[1] == L':') { 266*c34c9f81SPeter+ p = skip_drive(path); 267*c34c9f81SPeter+ } 268*c34c9f81SPeter+ else if (path[0] == L'\\') { 269*c34c9f81SPeter+ p = path + 1; 270*c34c9f81SPeter+ } 271*c34c9f81SPeter+ else { 272*c34c9f81SPeter+ return E_INVALIDARG; 273*c34c9f81SPeter+ } 274*c34c9f81SPeter+ 275*c34c9f81SPeter+ *root_end = p; 276*c34c9f81SPeter+ return S_OK; 277*c34c9f81SPeter+} 278*c34c9f81SPeter+ 279*c34c9f81SPeter+/* The extension is the last '.' in the final path segment; with none, 280*c34c9f81SPeter+ *ext is the terminating NUL. The string must end within cch characters. */ 281*c34c9f81SPeter+static HRESULT 282*c34c9f81SPeter+find_extension_fallback(PCWSTR path, size_t cch, PCWSTR *ext) 283*c34c9f81SPeter+{ 284*c34c9f81SPeter+ PCWSTR p; 285*c34c9f81SPeter+ PCWSTR dot = NULL; 286*c34c9f81SPeter+ 287*c34c9f81SPeter+ if (ext == NULL) { 288*c34c9f81SPeter+ return E_INVALIDARG; 289*c34c9f81SPeter+ } 290*c34c9f81SPeter+ *ext = NULL; 291*c34c9f81SPeter+ if (path == NULL || cch == 0 || cch > PATHCCH_MAX_CCH) { 292*c34c9f81SPeter+ return E_INVALIDARG; 293*c34c9f81SPeter+ } 294*c34c9f81SPeter+ for (p = path; p < path + cch && *p != L'\0'; ++p) { 295*c34c9f81SPeter+ if (*p == L'.') { 296*c34c9f81SPeter+ dot = p; 297*c34c9f81SPeter+ } 298*c34c9f81SPeter+ else if (*p == L'\\') { 299*c34c9f81SPeter+ dot = NULL; 300*c34c9f81SPeter+ } 301*c34c9f81SPeter+ } 302*c34c9f81SPeter+ if (p == path + cch) { 303*c34c9f81SPeter+ return E_INVALIDARG; /* not terminated */ 304*c34c9f81SPeter+ } 305*c34c9f81SPeter+ *ext = dot != NULL ? dot : p; 306*c34c9f81SPeter+ return S_OK; 307*c34c9f81SPeter+} 308*c34c9f81SPeter+ 309*c34c9f81SPeter+static HRESULT 310*c34c9f81SPeter+combine_ex_fallback(PWSTR out, size_t cch, PCWSTR in, PCWSTR more, 311*c34c9f81SPeter+ ULONG flags) 312*c34c9f81SPeter+{ 313*c34c9f81SPeter+ WCHAR combined[MAX_PATH]; 314*c34c9f81SPeter+ size_t len; 315*c34c9f81SPeter+ 316*c34c9f81SPeter+ (void)flags; /* long paths do not exist on Windows 7 */ 317*c34c9f81SPeter+ if (out == NULL || cch == 0 || cch > PATHCCH_MAX_CCH) { 318*c34c9f81SPeter+ return E_INVALIDARG; 319*c34c9f81SPeter+ } 320*c34c9f81SPeter+ out[0] = L'\0'; 321*c34c9f81SPeter+ if (PathCombineW(combined, in, more) == NULL) { 322*c34c9f81SPeter+ return HRESULT_FROM_WIN32(ERROR_FILENAME_EXCED_RANGE); 323*c34c9f81SPeter+ } 324*c34c9f81SPeter+ len = wcslen(combined); 325*c34c9f81SPeter+ if (len >= cch) { 326*c34c9f81SPeter+ return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); 327*c34c9f81SPeter+ } 328*c34c9f81SPeter+ memcpy(out, combined, (len + 1) * sizeof(WCHAR)); 329*c34c9f81SPeter+ return S_OK; 330*c34c9f81SPeter+} 331*c34c9f81SPeter+ 332*c34c9f81SPeter+static volatile LONG_PTR skip_root_slot; 333*c34c9f81SPeter+static volatile LONG_PTR find_extension_slot; 334*c34c9f81SPeter+static volatile LONG_PTR combine_ex_slot; 335*c34c9f81SPeter+ 336*c34c9f81SPeter+HRESULT WINAPI 337*c34c9f81SPeter+PathCchSkipRoot(PCWSTR pszPath, PCWSTR *ppszRootEnd) 338*c34c9f81SPeter+{ 339*c34c9f81SPeter+ skip_root_fn real = (skip_root_fn)kernelbase_export( 340*c34c9f81SPeter+ &skip_root_slot, "PathCchSkipRoot"); 341*c34c9f81SPeter+ return real != NULL ? real(pszPath, ppszRootEnd) 342*c34c9f81SPeter+ : skip_root_fallback(pszPath, ppszRootEnd); 343*c34c9f81SPeter+} 344*c34c9f81SPeter+ 345*c34c9f81SPeter+HRESULT WINAPI 346*c34c9f81SPeter+PathCchFindExtension(PCWSTR pszPath, size_t cchPath, PCWSTR *ppszExt) 347*c34c9f81SPeter+{ 348*c34c9f81SPeter+ find_extension_fn real = (find_extension_fn)kernelbase_export( 349*c34c9f81SPeter+ &find_extension_slot, "PathCchFindExtension"); 350*c34c9f81SPeter+ return real != NULL ? real(pszPath, cchPath, ppszExt) 351*c34c9f81SPeter+ : find_extension_fallback(pszPath, cchPath, ppszExt); 352*c34c9f81SPeter+} 353*c34c9f81SPeter+ 354*c34c9f81SPeter+HRESULT WINAPI 355*c34c9f81SPeter+PathCchCombineEx(PWSTR pszPathOut, size_t cchPathOut, PCWSTR pszPathIn, 356*c34c9f81SPeter+ PCWSTR pszMore, ULONG dwFlags) 357*c34c9f81SPeter+{ 358*c34c9f81SPeter+ combine_ex_fn real = (combine_ex_fn)kernelbase_export( 359*c34c9f81SPeter+ &combine_ex_slot, "PathCchCombineEx"); 360*c34c9f81SPeter+ return real != NULL 361*c34c9f81SPeter+ ? real(pszPathOut, cchPathOut, pszPathIn, pszMore, dwFlags) 362*c34c9f81SPeter+ : combine_ex_fallback(pszPathOut, cchPathOut, pszPathIn, pszMore, 363*c34c9f81SPeter+ dwFlags); 364*c34c9f81SPeter+} 365*c34c9f81SPeterdiff -ruN misc/Python-3.11.15/PC/pyconfig.h misc/build/Python-3.11.15/PC/pyconfig.h 366*c34c9f81SPeter--- misc/Python-3.11.15/PC/pyconfig.h 2025-01-01 00:00:00.000000000 +0000 367*c34c9f81SPeter+++ misc/build/Python-3.11.15/PC/pyconfig.h 2025-01-01 00:00:00.000000000 +0000 368*c34c9f81SPeter@@ -141,9 +141,12 @@ 369*c34c9f81SPeter #endif /* MS_WIN64 */ 370*c34c9f81SPeter 371*c34c9f81SPeter /* set the version macros for the windows headers */ 372*c34c9f81SPeter-/* Python 3.9+ requires Windows 8 or greater */ 373*c34c9f81SPeter-#define Py_WINVER 0x0602 /* _WIN32_WINNT_WIN8 */ 374*c34c9f81SPeter-#define Py_NTDDI NTDDI_WIN8 375*c34c9f81SPeter+/* Upstream Python 3.9+ requires Windows 8 or greater. Apache OpenOffice 376*c34c9f81SPeter+ builds it for Windows 7 SP1, its own floor: PC/pathcch_win7.c stands in for 377*c34c9f81SPeter+ the PathCch* functions Windows 7 lacks, and PC/aoo_win7_compat.h supplies 378*c34c9f81SPeter+ the few Windows 8 constants used without depending on Windows 8. */ 379*c34c9f81SPeter+#define Py_WINVER 0x0601 /* _WIN32_WINNT_WIN7 */ 380*c34c9f81SPeter+#define Py_NTDDI NTDDI_WIN7 381*c34c9f81SPeter 382*c34c9f81SPeter /* We only set these values when building Python - we don't want to force 383*c34c9f81SPeter these values on extensions, as that will affect the prototypes and 384*c34c9f81SPeterdiff -ruN misc/Python-3.11.15/PCbuild/pyproject.props misc/build/Python-3.11.15/PCbuild/pyproject.props 385*c34c9f81SPeter--- misc/Python-3.11.15/PCbuild/pyproject.props 2025-01-01 00:00:00.000000000 +0000 386*c34c9f81SPeter+++ misc/build/Python-3.11.15/PCbuild/pyproject.props 2025-01-01 00:00:00.000000000 +0000 387*c34c9f81SPeter@@ -39,6 +39,7 @@ 388*c34c9f81SPeter <ClCompile> 389*c34c9f81SPeter <AdditionalIncludeDirectories>$(PySourcePath)Include;$(PySourcePath)Include\internal;$(PySourcePath)PC;$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> 390*c34c9f81SPeter <PreprocessorDefinitions>WIN32;$(_Py3NamePreprocessorDefinition);$(_PlatformPreprocessorDefinition)$(_DebugPreprocessorDefinition)$(_PydPreprocessorDefinition)%(PreprocessorDefinitions)</PreprocessorDefinitions> 391*c34c9f81SPeter+ <ForcedIncludeFiles>aoo_win7_compat.h;%(ForcedIncludeFiles)</ForcedIncludeFiles> 392*c34c9f81SPeter 393*c34c9f81SPeter <Optimization>MaxSpeed</Optimization> 394*c34c9f81SPeter <IntrinsicFunctions>true</IntrinsicFunctions> 395*c34c9f81SPeterdiff -ruN misc/Python-3.11.15/PCbuild/pythoncore.vcxproj misc/build/Python-3.11.15/PCbuild/pythoncore.vcxproj 396*c34c9f81SPeter--- misc/Python-3.11.15/PCbuild/pythoncore.vcxproj 2025-01-01 00:00:00.000000000 +0000 397*c34c9f81SPeter+++ misc/build/Python-3.11.15/PCbuild/pythoncore.vcxproj 2025-01-01 00:00:00.000000000 +0000 398*c34c9f81SPeter@@ -106,7 +106,7 @@ 399*c34c9f81SPeter <PreprocessorDefinitions Condition="$(IncludeExternals)">_Py_HAVE_ZLIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> 400*c34c9f81SPeter </ClCompile> 401*c34c9f81SPeter <Link> 402*c34c9f81SPeter- <AdditionalDependencies>version.lib;ws2_32.lib;pathcch.lib;bcrypt.lib;%(AdditionalDependencies)</AdditionalDependencies> 403*c34c9f81SPeter+ <AdditionalDependencies>version.lib;ws2_32.lib;shlwapi.lib;bcrypt.lib;%(AdditionalDependencies)</AdditionalDependencies> 404*c34c9f81SPeter </Link> 405*c34c9f81SPeter </ItemDefinitionGroup> 406*c34c9f81SPeter <ItemGroup> 407*c34c9f81SPeter@@ -473,6 +473,7 @@ 408*c34c9f81SPeter <ClCompile Include="..\PC\invalid_parameter_handler.c" /> 409*c34c9f81SPeter <ClCompile Include="..\PC\winreg.c" /> 410*c34c9f81SPeter <ClCompile Include="..\PC\config.c" /> 411*c34c9f81SPeter+ <ClCompile Include="..\PC\pathcch_win7.c" /> 412*c34c9f81SPeter <ClCompile Include="..\PC\msvcrtmodule.c" /> 413*c34c9f81SPeter <ClCompile Include="..\Python\pyhash.c" /> 414*c34c9f81SPeter <ClCompile Include="..\Python\_warnings.c" /> 415