mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
Fix GetNamedPipeHandleStateW on non-desktop Windows API partitions (GH-134049)
This commit is contained in:
parent
52a7a22a6b
commit
20095fb29a
1 changed files with 37 additions and 0 deletions
|
@ -2784,6 +2784,43 @@ error:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#else /* MS_WINDOWS */
|
#else /* MS_WINDOWS */
|
||||||
|
|
||||||
|
// The Windows Games API family doesn't expose GetNamedPipeHandleStateW so attempt
|
||||||
|
// to load it directly from the Kernel32.dll
|
||||||
|
#if !defined(MS_WINDOWS_APP) && !defined(MS_WINDOWS_SYSTEM)
|
||||||
|
BOOL
|
||||||
|
GetNamedPipeHandleStateW(HANDLE hNamedPipe, LPDWORD lpState, LPDWORD lpCurInstances, LPDWORD lpMaxCollectionCount,
|
||||||
|
LPDWORD lpCollectDataTimeout, LPWSTR lpUserName, DWORD nMaxUserNameSize)
|
||||||
|
{
|
||||||
|
static int initialized = 0;
|
||||||
|
typedef BOOL(__stdcall* PGetNamedPipeHandleStateW) (
|
||||||
|
HANDLE hNamedPipe, LPDWORD lpState, LPDWORD lpCurInstances, LPDWORD lpMaxCollectionCount,
|
||||||
|
LPDWORD lpCollectDataTimeout, LPWSTR lpUserName, DWORD nMaxUserNameSize);
|
||||||
|
static PGetNamedPipeHandleStateW _GetNamedPipeHandleStateW;
|
||||||
|
|
||||||
|
if (initialized == 0) {
|
||||||
|
HMODULE api = LoadLibraryExW(L"Kernel32.dll", NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);
|
||||||
|
if (api) {
|
||||||
|
_GetNamedPipeHandleStateW = (PGetNamedPipeHandleStateW)GetProcAddress(
|
||||||
|
api, "GetNamedPipeHandleStateW");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
_GetNamedPipeHandleStateW = NULL;
|
||||||
|
}
|
||||||
|
initialized = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_GetNamedPipeHandleStateW) {
|
||||||
|
SetLastError(E_NOINTERFACE);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _GetNamedPipeHandleStateW(
|
||||||
|
hNamedPipe, lpState, lpCurInstances, lpMaxCollectionCount, lpCollectDataTimeout, lpUserName, nMaxUserNameSize
|
||||||
|
);
|
||||||
|
}
|
||||||
|
#endif /* !MS_WINDOWS_APP && !MS_WINDOWS_SYSTEM */
|
||||||
|
|
||||||
int
|
int
|
||||||
_Py_get_blocking(int fd)
|
_Py_get_blocking(int fd)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue