diff --git a/Include/internal/pycore_fileutils_windows.h b/Include/internal/pycore_fileutils_windows.h index b79aa9fb4653765..4c42f16beb12a4f 100644 --- a/Include/internal/pycore_fileutils_windows.h +++ b/Include/internal/pycore_fileutils_windows.h @@ -55,7 +55,11 @@ static inline BOOL _Py_GetFileInformationByName( static int GetFileInformationByName_init = -1; if (GetFileInformationByName_init < 0) { +#ifdef MS_WINDOWS_DESKTOP HMODULE hMod = LoadLibraryW(L"api-ms-win-core-file-l2-1-4"); +#else + HMODULE hMod = LoadPackagedLibrary(L"api-ms-win-core-file-l2-1-4", 0); +#endif GetFileInformationByName_init = 0; if (hMod) { GetFileInformationByName = (PGetFileInformationByName)GetProcAddress( diff --git a/Modules/clinic/posixmodule.c.h b/Modules/clinic/posixmodule.c.h index 00a4f6009186af9..1f7e414b2dfe48f 100644 --- a/Modules/clinic/posixmodule.c.h +++ b/Modules/clinic/posixmodule.c.h @@ -1851,7 +1851,7 @@ os_listdrives(PyObject *module, PyObject *Py_UNUSED(ignored)) #endif /* (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM)) */ -#if (defined(MS_WINDOWS_APP) || defined(MS_WINDOWS_SYSTEM)) +#if (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM)) PyDoc_STRVAR(os_listvolumes__doc__, "listvolumes($module, /)\n" @@ -1873,7 +1873,7 @@ os_listvolumes(PyObject *module, PyObject *Py_UNUSED(ignored)) return os_listvolumes_impl(module); } -#endif /* (defined(MS_WINDOWS_APP) || defined(MS_WINDOWS_SYSTEM)) */ +#endif /* (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM)) */ #if (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM)) @@ -13733,4 +13733,4 @@ os__emscripten_log(PyObject *module, PyObject *const *args, Py_ssize_t nargs, Py #ifndef OS__EMSCRIPTEN_LOG_METHODDEF #define OS__EMSCRIPTEN_LOG_METHODDEF #endif /* !defined(OS__EMSCRIPTEN_LOG_METHODDEF) */ -/*[clinic end generated code: output=250ea2e34fdd133f input=a9049054013a1b77]*/ +/*[clinic end generated code: output=d81494ceb6ce44ed input=a9049054013a1b77]*/ diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 57db175336702e2..36debd6fe7aa153 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -5197,7 +5197,7 @@ os_listdrives_impl(PyObject *module) #endif /* MS_WINDOWS_DESKTOP || MS_WINDOWS_SYSTEM */ -#if defined(MS_WINDOWS_APP) || defined(MS_WINDOWS_SYSTEM) +#if defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) /*[clinic input] os.listvolumes @@ -5260,7 +5260,7 @@ os_listvolumes_impl(PyObject *module) return result; } -#endif /* MS_WINDOWS_APP || MS_WINDOWS_SYSTEM */ +#endif /* MS_WINDOWS_DESKTOP || MS_WINDOWS_SYSTEM */ #if defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) @@ -9933,6 +9933,7 @@ os_setpgrp_impl(PyObject *module) #include #include +#ifdef MS_WINDOWS_DESKTOP // The structure definition in winternl.h may be incomplete. // This structure is the full version from the MSDN documentation. typedef struct _PROCESS_BASIC_INFORMATION_FULL { @@ -10005,6 +10006,7 @@ win32_getppid_fast(void) cached_ppid = (ULONG) basic_information.InheritedFromUniqueProcessId; return cached_ppid; } +#endif // MS_WINDOWS_DESKTOP static PyObject* win32_getppid(void) @@ -10013,12 +10015,13 @@ win32_getppid(void) PyObject* result = NULL; HANDLE process = GetCurrentProcess(); HPSS snapshot = NULL; - ULONG pid; - pid = win32_getppid_fast(); +#ifdef MS_WINDOWS_DESKTOP + ULONG pid = win32_getppid_fast(); if (pid != 0) { return PyLong_FromUnsignedLong(pid); } +#endif // If failure occurs in win32_getppid_fast(), fall back to using the PSS API.