diff --git a/src/WinUsb/PublicAPI.Unshipped.txt b/src/WinUsb/PublicAPI.Unshipped.txt index 4b7c1be2..346e036f 100644 --- a/src/WinUsb/PublicAPI.Unshipped.txt +++ b/src/WinUsb/PublicAPI.Unshipped.txt @@ -25,6 +25,8 @@ static PInvoke.WinUsb.WinUsb_WritePipe(PInvoke.WinUsb.SafeUsbHandle interfaceHan static PInvoke.WinUsb.WinUsb_WritePipe(PInvoke.WinUsb.SafeUsbHandle interfaceHandle, byte pipeID, byte[] buffer, int bufferLength, out int lengthTransferred, System.Threading.NativeOverlapped? overlapped) -> bool static PInvoke.WinUsb.WinUsb_WritePipeAsync(PInvoke.WinUsb.SafeUsbHandle interfaceHandle, byte pipeID, System.ReadOnlyMemory buffer, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.ValueTask static extern PInvoke.WinUsb.WinUsb_AbortPipe(PInvoke.WinUsb.SafeUsbHandle handle, byte pipeID) -> bool +static extern PInvoke.WinUsb.WinUsb_FlushPipe(PInvoke.WinUsb.SafeUsbHandle interfaceHandle, byte pipeID) -> bool +static extern PInvoke.WinUsb.WinUsb_GetAssociatedInterface(PInvoke.WinUsb.SafeUsbHandle interfaceHandle, byte associatedInterfaceIndex, out PInvoke.WinUsb.SafeUsbHandle associatedInterfaceHandle) -> bool static extern PInvoke.WinUsb.WinUsb_Initialize(PInvoke.Kernel32.SafeObjectHandle deviceHandle, out PInvoke.WinUsb.SafeUsbHandle interfaceHandle) -> bool static extern PInvoke.WinUsb.WinUsb_QueryPipe(PInvoke.WinUsb.SafeUsbHandle interfaceHandle, byte alternateInterfaceNumber, byte pipeIndex, PInvoke.WinUsb.WINUSB_PIPE_INFORMATION* pipeInformation) -> bool static extern PInvoke.WinUsb.WinUsb_ReadPipe(PInvoke.WinUsb.SafeUsbHandle interfaceHandle, byte pipeID, byte* buffer, int bufferLength, out int lengthTransferred, System.Threading.NativeOverlapped* overlapped) -> bool diff --git a/src/WinUsb/WinUsb.cs b/src/WinUsb/WinUsb.cs index 8bcb8b68..5ee44592 100644 --- a/src/WinUsb/WinUsb.cs +++ b/src/WinUsb/WinUsb.cs @@ -61,6 +61,53 @@ public static unsafe extern bool WinUsb_QueryPipe( byte pipeIndex, [Friendly(FriendlyFlags.Out)] WINUSB_PIPE_INFORMATION* pipeInformation); + /// + /// The function discards any data that is cached in a pipe. This is a synchronous operation. + /// + /// + /// An opaque handle to the interface with which the specified pipe's endpoint is associated. To clear data in a pipe that is + /// associated with the endpoint on the first (default) interface, use the handle returned by . + /// For all other interfaces, use the handle to the target interface, retrieved by . + /// + /// + /// The identifier (ID) of the control pipe. The PipeID parameter is an 8-bit value that consists of a 7-bit address and a direction bit. + /// This parameter corresponds to the bEndpointAddress field in the endpoint descriptor. + /// + /// + /// returns if the operation succeeds. Otherwise, this routine returns + /// , and the caller can retrieve the logged error by calling . + /// + [DllImport(nameof(WinUsb), SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static unsafe extern bool WinUsb_FlushPipe( + SafeUsbHandle interfaceHandle, + byte pipeID); + + /// + /// The function retrieves a handle for an associated interface. This is a synchronous operation. + /// + /// + /// An opaque handle to the first (default) interface on the device, which is returned by . + /// + /// + /// An index that specifies the associated interface to retrieve. A value of 0 indicates the first associated interface, + /// a value of 1 indicates the second associated interface, and so on. + /// + /// + /// A handle for the associated interface. Callers must pass this interface handle to WinUSB Functions exposed by Winusb.dll. + /// To close this handle, call . + /// + /// + /// returns if the operation succeeds. Otherwise, this routine returns + /// , and the caller can retrieve the logged error by calling . + /// + [DllImport(nameof(WinUsb), SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static unsafe extern bool WinUsb_GetAssociatedInterface( + SafeUsbHandle interfaceHandle, + byte associatedInterfaceIndex, + out SafeUsbHandle associatedInterfaceHandle); + /// /// Writes data to a pipe. ///