11cb0ef41Sopenharmony_ci/* MIT License 21cb0ef41Sopenharmony_ci * 31cb0ef41Sopenharmony_ci * Copyright (c) 2024 Brad House 41cb0ef41Sopenharmony_ci * 51cb0ef41Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a copy 61cb0ef41Sopenharmony_ci * of this software and associated documentation files (the "Software"), to deal 71cb0ef41Sopenharmony_ci * in the Software without restriction, including without limitation the rights 81cb0ef41Sopenharmony_ci * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 91cb0ef41Sopenharmony_ci * copies of the Software, and to permit persons to whom the Software is 101cb0ef41Sopenharmony_ci * furnished to do so, subject to the following conditions: 111cb0ef41Sopenharmony_ci * 121cb0ef41Sopenharmony_ci * The above copyright notice and this permission notice (including the next 131cb0ef41Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 141cb0ef41Sopenharmony_ci * Software. 151cb0ef41Sopenharmony_ci * 161cb0ef41Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 171cb0ef41Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 181cb0ef41Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 191cb0ef41Sopenharmony_ci * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 201cb0ef41Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 211cb0ef41Sopenharmony_ci * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 221cb0ef41Sopenharmony_ci * SOFTWARE. 231cb0ef41Sopenharmony_ci * 241cb0ef41Sopenharmony_ci * SPDX-License-Identifier: MIT 251cb0ef41Sopenharmony_ci */ 261cb0ef41Sopenharmony_ci#ifndef __ARES_EVENT_WIN32_H 271cb0ef41Sopenharmony_ci#define __ARES_EVENT_WIN32_H 281cb0ef41Sopenharmony_ci 291cb0ef41Sopenharmony_ci#ifdef _WIN32 301cb0ef41Sopenharmony_ci# ifdef HAVE_WINSOCK2_H 311cb0ef41Sopenharmony_ci# include <winsock2.h> 321cb0ef41Sopenharmony_ci# endif 331cb0ef41Sopenharmony_ci# ifdef HAVE_WS2TCPIP_H 341cb0ef41Sopenharmony_ci# include <ws2tcpip.h> 351cb0ef41Sopenharmony_ci# endif 361cb0ef41Sopenharmony_ci# ifdef HAVE_MSWSOCK_H 371cb0ef41Sopenharmony_ci# include <mswsock.h> 381cb0ef41Sopenharmony_ci# endif 391cb0ef41Sopenharmony_ci# ifdef HAVE_WINDOWS_H 401cb0ef41Sopenharmony_ci# include <windows.h> 411cb0ef41Sopenharmony_ci# endif 421cb0ef41Sopenharmony_ci 431cb0ef41Sopenharmony_ci/* From winternl.h */ 441cb0ef41Sopenharmony_ci 451cb0ef41Sopenharmony_ci/* If WDK is not installed and not using MinGW, provide the needed definitions 461cb0ef41Sopenharmony_ci */ 471cb0ef41Sopenharmony_citypedef LONG NTSTATUS; 481cb0ef41Sopenharmony_ci 491cb0ef41Sopenharmony_citypedef struct _IO_STATUS_BLOCK { 501cb0ef41Sopenharmony_ci union { 511cb0ef41Sopenharmony_ci NTSTATUS Status; 521cb0ef41Sopenharmony_ci PVOID Pointer; 531cb0ef41Sopenharmony_ci }; 541cb0ef41Sopenharmony_ci 551cb0ef41Sopenharmony_ci ULONG_PTR Information; 561cb0ef41Sopenharmony_ci} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK; 571cb0ef41Sopenharmony_ci 581cb0ef41Sopenharmony_citypedef VOID(NTAPI *PIO_APC_ROUTINE)(PVOID ApcContext, 591cb0ef41Sopenharmony_ci PIO_STATUS_BLOCK IoStatusBlock, 601cb0ef41Sopenharmony_ci ULONG Reserved); 611cb0ef41Sopenharmony_ci 621cb0ef41Sopenharmony_ci/* From ntstatus.h */ 631cb0ef41Sopenharmony_ci# define STATUS_SUCCESS ((NTSTATUS)0x00000000) 641cb0ef41Sopenharmony_ci# ifndef STATUS_PENDING 651cb0ef41Sopenharmony_ci# define STATUS_PENDING ((NTSTATUS)0x00000103L) 661cb0ef41Sopenharmony_ci# endif 671cb0ef41Sopenharmony_ci# define STATUS_CANCELLED ((NTSTATUS)0xC0000120L) 681cb0ef41Sopenharmony_ci# define STATUS_NOT_FOUND ((NTSTATUS)0xC0000225L) 691cb0ef41Sopenharmony_ci 701cb0ef41Sopenharmony_ci/* Not sure what headers might have these */ 711cb0ef41Sopenharmony_ci# define IOCTL_AFD_POLL 0x00012024 721cb0ef41Sopenharmony_ci 731cb0ef41Sopenharmony_ci# define AFD_POLL_RECEIVE 0x0001 741cb0ef41Sopenharmony_ci# define AFD_POLL_RECEIVE_EXPEDITED 0x0002 751cb0ef41Sopenharmony_ci# define AFD_POLL_SEND 0x0004 761cb0ef41Sopenharmony_ci# define AFD_POLL_DISCONNECT 0x0008 771cb0ef41Sopenharmony_ci# define AFD_POLL_ABORT 0x0010 781cb0ef41Sopenharmony_ci# define AFD_POLL_LOCAL_CLOSE 0x0020 791cb0ef41Sopenharmony_ci# define AFD_POLL_ACCEPT 0x0080 801cb0ef41Sopenharmony_ci# define AFD_POLL_CONNECT_FAIL 0x0100 811cb0ef41Sopenharmony_ci 821cb0ef41Sopenharmony_citypedef struct _AFD_POLL_HANDLE_INFO { 831cb0ef41Sopenharmony_ci HANDLE Handle; 841cb0ef41Sopenharmony_ci ULONG Events; 851cb0ef41Sopenharmony_ci NTSTATUS Status; 861cb0ef41Sopenharmony_ci} AFD_POLL_HANDLE_INFO, *PAFD_POLL_HANDLE_INFO; 871cb0ef41Sopenharmony_ci 881cb0ef41Sopenharmony_citypedef struct _AFD_POLL_INFO { 891cb0ef41Sopenharmony_ci LARGE_INTEGER Timeout; 901cb0ef41Sopenharmony_ci ULONG NumberOfHandles; 911cb0ef41Sopenharmony_ci ULONG Exclusive; 921cb0ef41Sopenharmony_ci AFD_POLL_HANDLE_INFO Handles[1]; 931cb0ef41Sopenharmony_ci} AFD_POLL_INFO, *PAFD_POLL_INFO; 941cb0ef41Sopenharmony_ci 951cb0ef41Sopenharmony_ci/* Prototypes for dynamically loaded functions from ntdll.dll */ 961cb0ef41Sopenharmony_citypedef NTSTATUS(NTAPI *NtCancelIoFileEx_t)(HANDLE FileHandle, 971cb0ef41Sopenharmony_ci PIO_STATUS_BLOCK IoRequestToCancel, 981cb0ef41Sopenharmony_ci PIO_STATUS_BLOCK IoStatusBlock); 991cb0ef41Sopenharmony_citypedef NTSTATUS(NTAPI *NtDeviceIoControlFile_t)( 1001cb0ef41Sopenharmony_ci HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext, 1011cb0ef41Sopenharmony_ci PIO_STATUS_BLOCK IoStatusBlock, ULONG IoControlCode, PVOID InputBuffer, 1021cb0ef41Sopenharmony_ci ULONG InputBufferLength, PVOID OutputBuffer, ULONG OutputBufferLength); 1031cb0ef41Sopenharmony_ci 1041cb0ef41Sopenharmony_ci/* On UWP/Windows Store, these definitions aren't there for some reason */ 1051cb0ef41Sopenharmony_ci# ifndef SIO_BSP_HANDLE_POLL 1061cb0ef41Sopenharmony_ci# define SIO_BSP_HANDLE_POLL 0x4800001D 1071cb0ef41Sopenharmony_ci# endif 1081cb0ef41Sopenharmony_ci 1091cb0ef41Sopenharmony_ci# ifndef SIO_BASE_HANDLE 1101cb0ef41Sopenharmony_ci# define SIO_BASE_HANDLE 0x48000022 1111cb0ef41Sopenharmony_ci# endif 1121cb0ef41Sopenharmony_ci 1131cb0ef41Sopenharmony_ci# ifndef HANDLE_FLAG_INHERIT 1141cb0ef41Sopenharmony_ci# define HANDLE_FLAG_INHERIT 0x00000001 1151cb0ef41Sopenharmony_ci# endif 1161cb0ef41Sopenharmony_ci 1171cb0ef41Sopenharmony_ci#endif /* _WIN32 */ 1181cb0ef41Sopenharmony_ci 1191cb0ef41Sopenharmony_ci#endif /* __ARES_EVENT_WIN32_H */ 120