xref: /aosp_15_r20/development/host/windows/usb/api/adb_api.h (revision 90c8c64db3049935a07c6143d7fd006e26f8ecca)
1*90c8c64dSAndroid Build Coastguard Worker /*
2*90c8c64dSAndroid Build Coastguard Worker  * Copyright (C) 2006 The Android Open Source Project
3*90c8c64dSAndroid Build Coastguard Worker  *
4*90c8c64dSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*90c8c64dSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*90c8c64dSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*90c8c64dSAndroid Build Coastguard Worker  *
8*90c8c64dSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*90c8c64dSAndroid Build Coastguard Worker  *
10*90c8c64dSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*90c8c64dSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*90c8c64dSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*90c8c64dSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*90c8c64dSAndroid Build Coastguard Worker  * limitations under the License.
15*90c8c64dSAndroid Build Coastguard Worker  */
16*90c8c64dSAndroid Build Coastguard Worker 
17*90c8c64dSAndroid Build Coastguard Worker #ifndef ANDROID_USB_API_ADBWINAPI_H__
18*90c8c64dSAndroid Build Coastguard Worker #define ANDROID_USB_API_ADBWINAPI_H__
19*90c8c64dSAndroid Build Coastguard Worker 
20*90c8c64dSAndroid Build Coastguard Worker #include <windows.h>
21*90c8c64dSAndroid Build Coastguard Worker #include <usb100.h>
22*90c8c64dSAndroid Build Coastguard Worker 
23*90c8c64dSAndroid Build Coastguard Worker /** \file
24*90c8c64dSAndroid Build Coastguard Worker   This file consists of declarations of routines exported by the API as well
25*90c8c64dSAndroid Build Coastguard Worker   as types, structures, and constants definitions used in the API.
26*90c8c64dSAndroid Build Coastguard Worker */
27*90c8c64dSAndroid Build Coastguard Worker 
28*90c8c64dSAndroid Build Coastguard Worker // Enables compillation for "straight" C
29*90c8c64dSAndroid Build Coastguard Worker #ifdef __cplusplus
30*90c8c64dSAndroid Build Coastguard Worker   #define EXTERN_C    extern "C"
31*90c8c64dSAndroid Build Coastguard Worker #else
32*90c8c64dSAndroid Build Coastguard Worker   #define EXTERN_C    extern
33*90c8c64dSAndroid Build Coastguard Worker   typedef int bool;
34*90c8c64dSAndroid Build Coastguard Worker   #define true  1
35*90c8c64dSAndroid Build Coastguard Worker   #define false 0
36*90c8c64dSAndroid Build Coastguard Worker #endif
37*90c8c64dSAndroid Build Coastguard Worker 
38*90c8c64dSAndroid Build Coastguard Worker /** \brief Enumerates ADB endpoint types.
39*90c8c64dSAndroid Build Coastguard Worker 
40*90c8c64dSAndroid Build Coastguard Worker   This enum is taken from WDF_USB_PIPE_TYPE enum found in WDK.
41*90c8c64dSAndroid Build Coastguard Worker */
42*90c8c64dSAndroid Build Coastguard Worker typedef enum _AdbEndpointType {
43*90c8c64dSAndroid Build Coastguard Worker   /// Unknown (invalid, or not initialized) endpoint type.
44*90c8c64dSAndroid Build Coastguard Worker   AdbEndpointTypeInvalid = 0,
45*90c8c64dSAndroid Build Coastguard Worker 
46*90c8c64dSAndroid Build Coastguard Worker   /// Endpoint is device control pipe.
47*90c8c64dSAndroid Build Coastguard Worker   AdbEndpointTypeControl,
48*90c8c64dSAndroid Build Coastguard Worker 
49*90c8c64dSAndroid Build Coastguard Worker   /// Endpoint is isochronous r/w pipe.
50*90c8c64dSAndroid Build Coastguard Worker   AdbEndpointTypeIsochronous,
51*90c8c64dSAndroid Build Coastguard Worker 
52*90c8c64dSAndroid Build Coastguard Worker   /// Endpoint is a bulk r/w pipe.
53*90c8c64dSAndroid Build Coastguard Worker   AdbEndpointTypeBulk,
54*90c8c64dSAndroid Build Coastguard Worker 
55*90c8c64dSAndroid Build Coastguard Worker   /// Endpoint is an interrupt r/w pipe.
56*90c8c64dSAndroid Build Coastguard Worker   AdbEndpointTypeInterrupt,
57*90c8c64dSAndroid Build Coastguard Worker } AdbEndpointType;
58*90c8c64dSAndroid Build Coastguard Worker 
59*90c8c64dSAndroid Build Coastguard Worker /** \brief Endpoint desriptor.
60*90c8c64dSAndroid Build Coastguard Worker 
61*90c8c64dSAndroid Build Coastguard Worker   This structure is based on WDF_USB_PIPE_INFORMATION structure found in WDK.
62*90c8c64dSAndroid Build Coastguard Worker */
63*90c8c64dSAndroid Build Coastguard Worker typedef struct _AdbEndpointInformation {
64*90c8c64dSAndroid Build Coastguard Worker   /// Maximum packet size this endpoint is capable of.
65*90c8c64dSAndroid Build Coastguard Worker   unsigned long max_packet_size;
66*90c8c64dSAndroid Build Coastguard Worker 
67*90c8c64dSAndroid Build Coastguard Worker   /// Maximum size of one transfer which should be sent to the host controller.
68*90c8c64dSAndroid Build Coastguard Worker   unsigned long max_transfer_size;
69*90c8c64dSAndroid Build Coastguard Worker 
70*90c8c64dSAndroid Build Coastguard Worker   /// ADB endpoint type.
71*90c8c64dSAndroid Build Coastguard Worker   AdbEndpointType endpoint_type;
72*90c8c64dSAndroid Build Coastguard Worker 
73*90c8c64dSAndroid Build Coastguard Worker   /// Raw endpoint address on the device as described by its descriptor.
74*90c8c64dSAndroid Build Coastguard Worker   unsigned char endpoint_address;
75*90c8c64dSAndroid Build Coastguard Worker 
76*90c8c64dSAndroid Build Coastguard Worker   /// Polling interval.
77*90c8c64dSAndroid Build Coastguard Worker   unsigned char polling_interval;
78*90c8c64dSAndroid Build Coastguard Worker 
79*90c8c64dSAndroid Build Coastguard Worker   /// Which alternate setting this structure is relevant for.
80*90c8c64dSAndroid Build Coastguard Worker   unsigned char setting_index;
81*90c8c64dSAndroid Build Coastguard Worker } AdbEndpointInformation;
82*90c8c64dSAndroid Build Coastguard Worker 
83*90c8c64dSAndroid Build Coastguard Worker /// Shortcut to default write bulk endpoint in zero-based endpoint index API.
84*90c8c64dSAndroid Build Coastguard Worker #define ADB_QUERY_BULK_WRITE_ENDPOINT_INDEX  0xFC
85*90c8c64dSAndroid Build Coastguard Worker 
86*90c8c64dSAndroid Build Coastguard Worker /// Shortcut to default read bulk endpoint in zero-based endpoint index API.
87*90c8c64dSAndroid Build Coastguard Worker #define ADB_QUERY_BULK_READ_ENDPOINT_INDEX  0xFE
88*90c8c64dSAndroid Build Coastguard Worker 
89*90c8c64dSAndroid Build Coastguard Worker // {F72FE0D4-CBCB-407d-8814-9ED673D0DD6B}
90*90c8c64dSAndroid Build Coastguard Worker /// Our USB class id that driver uses to register our device.
91*90c8c64dSAndroid Build Coastguard Worker #define ANDROID_USB_CLASS_ID \
92*90c8c64dSAndroid Build Coastguard Worker {0xf72fe0d4, 0xcbcb, 0x407d, {0x88, 0x14, 0x9e, 0xd6, 0x73, 0xd0, 0xdd, 0x6b}};
93*90c8c64dSAndroid Build Coastguard Worker 
94*90c8c64dSAndroid Build Coastguard Worker // The following ifdef block is the standard way of creating macros which make
95*90c8c64dSAndroid Build Coastguard Worker // exporting  from a DLL simpler. All files within this DLL are compiled with
96*90c8c64dSAndroid Build Coastguard Worker // the ADBWIN_EXPORTS symbol defined on the command line. this symbol should
97*90c8c64dSAndroid Build Coastguard Worker // not be defined on any project that uses this DLL. This way any other project
98*90c8c64dSAndroid Build Coastguard Worker // whose source files include this file see ADBWIN_API functions as being
99*90c8c64dSAndroid Build Coastguard Worker // imported from a DLL, whereas this DLL sees symbols defined with this macro
100*90c8c64dSAndroid Build Coastguard Worker // as being exported.
101*90c8c64dSAndroid Build Coastguard Worker #ifdef ADBWIN_EXPORTS
102*90c8c64dSAndroid Build Coastguard Worker #define ADBWIN_API EXTERN_C __declspec(dllexport)
103*90c8c64dSAndroid Build Coastguard Worker #define ADBWIN_API_CLASS     __declspec(dllexport)
104*90c8c64dSAndroid Build Coastguard Worker #else
105*90c8c64dSAndroid Build Coastguard Worker #define ADBWIN_API EXTERN_C __declspec(dllimport)
106*90c8c64dSAndroid Build Coastguard Worker #define ADBWIN_API_CLASS     __declspec(dllimport)
107*90c8c64dSAndroid Build Coastguard Worker #endif
108*90c8c64dSAndroid Build Coastguard Worker 
109*90c8c64dSAndroid Build Coastguard Worker /** \brief Handle to an API object.
110*90c8c64dSAndroid Build Coastguard Worker 
111*90c8c64dSAndroid Build Coastguard Worker   To access USB interface and its components clients must first obtain a
112*90c8c64dSAndroid Build Coastguard Worker   handle to the required object. API Objects that are represented by a
113*90c8c64dSAndroid Build Coastguard Worker   handle are:
114*90c8c64dSAndroid Build Coastguard Worker   1. Interface enumerator that provides access to a list of interfaces that
115*90c8c64dSAndroid Build Coastguard Worker      match certain criterias that were specified when interface enumerator
116*90c8c64dSAndroid Build Coastguard Worker      has been created. This handle is created in AdbEnumInterfaces routine.
117*90c8c64dSAndroid Build Coastguard Worker   2. Interface that is the major object this API deals with. In Windows
118*90c8c64dSAndroid Build Coastguard Worker      model of the USB stack each USB device (that is physical device,
119*90c8c64dSAndroid Build Coastguard Worker      attached to a USB port) exposes one or more interfaces that become the
120*90c8c64dSAndroid Build Coastguard Worker      major entities through which that device gets accessed. Each of these
121*90c8c64dSAndroid Build Coastguard Worker      interfaces are represented as Windows Device Objects on the USB stack.
122*90c8c64dSAndroid Build Coastguard Worker      So, to this extent, at least as this API is concerned, terms "interface"
123*90c8c64dSAndroid Build Coastguard Worker      and "device" are interchangeable, since each interface is represented by
124*90c8c64dSAndroid Build Coastguard Worker      a device object on the Windows USB stack. This handle is created in
125*90c8c64dSAndroid Build Coastguard Worker      either AdbCreateInterface or AdbCreateInterfaceByName routines.
126*90c8c64dSAndroid Build Coastguard Worker   3. Endpoint object (also called a pipe) represents an endpoint on interface
127*90c8c64dSAndroid Build Coastguard Worker      through which all I/O operations are performed. This handle is created in
128*90c8c64dSAndroid Build Coastguard Worker      one of these routines: AdbOpenEndpoint, AdbOpenDefaultBulkReadEndpoint,
129*90c8c64dSAndroid Build Coastguard Worker      or AdbOpenDefaultBulkWriteEndpoint.
130*90c8c64dSAndroid Build Coastguard Worker   4. I/O completion object that tracks completion information of asynchronous
131*90c8c64dSAndroid Build Coastguard Worker      I/O performed on an endpoint. When an endpoint object gets opened through
132*90c8c64dSAndroid Build Coastguard Worker      this API it is opened for asynchronous (or overlapped) I/O. And each time
133*90c8c64dSAndroid Build Coastguard Worker      an asynchronous I/O is performed by this API an I/O completion object is
134*90c8c64dSAndroid Build Coastguard Worker      created to track the result of that I/O when it gets completed. Clients
135*90c8c64dSAndroid Build Coastguard Worker      of the API can then use a handle to I/O completion object to query for
136*90c8c64dSAndroid Build Coastguard Worker      the status and result of asynchronous I/O as well as wait for this I/O
137*90c8c64dSAndroid Build Coastguard Worker      completion. This handle is created in one of these routines:
138*90c8c64dSAndroid Build Coastguard Worker      AdbReadEndpointAsync, or AdbWriteEndpointAsync.
139*90c8c64dSAndroid Build Coastguard Worker   After object is no longer needed by the client, its handle must be closed
140*90c8c64dSAndroid Build Coastguard Worker   using AdbCloseHandle routine.
141*90c8c64dSAndroid Build Coastguard Worker */
142*90c8c64dSAndroid Build Coastguard Worker typedef void* ADBAPIHANDLE;
143*90c8c64dSAndroid Build Coastguard Worker 
144*90c8c64dSAndroid Build Coastguard Worker /** \brief Defines access type with which an I/O object (endpoint)
145*90c8c64dSAndroid Build Coastguard Worker   should be opened.
146*90c8c64dSAndroid Build Coastguard Worker */
147*90c8c64dSAndroid Build Coastguard Worker typedef enum _AdbOpenAccessType {
148*90c8c64dSAndroid Build Coastguard Worker   /// Opens for read and write access.
149*90c8c64dSAndroid Build Coastguard Worker   AdbOpenAccessTypeReadWrite,
150*90c8c64dSAndroid Build Coastguard Worker 
151*90c8c64dSAndroid Build Coastguard Worker   /// Opens for read only access.
152*90c8c64dSAndroid Build Coastguard Worker   AdbOpenAccessTypeRead,
153*90c8c64dSAndroid Build Coastguard Worker 
154*90c8c64dSAndroid Build Coastguard Worker   /// Opens for write only access.
155*90c8c64dSAndroid Build Coastguard Worker   AdbOpenAccessTypeWrite,
156*90c8c64dSAndroid Build Coastguard Worker 
157*90c8c64dSAndroid Build Coastguard Worker   /// Opens for querying information.
158*90c8c64dSAndroid Build Coastguard Worker   AdbOpenAccessTypeQueryInfo,
159*90c8c64dSAndroid Build Coastguard Worker } AdbOpenAccessType;
160*90c8c64dSAndroid Build Coastguard Worker 
161*90c8c64dSAndroid Build Coastguard Worker /** \brief Defines sharing mode with which an I/O object (endpoint)
162*90c8c64dSAndroid Build Coastguard Worker   should be opened.
163*90c8c64dSAndroid Build Coastguard Worker */
164*90c8c64dSAndroid Build Coastguard Worker typedef enum _AdbOpenSharingMode {
165*90c8c64dSAndroid Build Coastguard Worker   /// Shares read and write.
166*90c8c64dSAndroid Build Coastguard Worker   AdbOpenSharingModeReadWrite,
167*90c8c64dSAndroid Build Coastguard Worker 
168*90c8c64dSAndroid Build Coastguard Worker   /// Shares only read.
169*90c8c64dSAndroid Build Coastguard Worker   AdbOpenSharingModeRead,
170*90c8c64dSAndroid Build Coastguard Worker 
171*90c8c64dSAndroid Build Coastguard Worker   /// Shares only write.
172*90c8c64dSAndroid Build Coastguard Worker   AdbOpenSharingModeWrite,
173*90c8c64dSAndroid Build Coastguard Worker 
174*90c8c64dSAndroid Build Coastguard Worker   /// Opens exclusive.
175*90c8c64dSAndroid Build Coastguard Worker   AdbOpenSharingModeExclusive,
176*90c8c64dSAndroid Build Coastguard Worker } AdbOpenSharingMode;
177*90c8c64dSAndroid Build Coastguard Worker 
178*90c8c64dSAndroid Build Coastguard Worker /** \brief Provides information about an interface.
179*90c8c64dSAndroid Build Coastguard Worker */
180*90c8c64dSAndroid Build Coastguard Worker typedef struct _AdbInterfaceInfo {
181*90c8c64dSAndroid Build Coastguard Worker   /// Inteface's class id (see SP_DEVICE_INTERFACE_DATA for details)
182*90c8c64dSAndroid Build Coastguard Worker   GUID          class_id;
183*90c8c64dSAndroid Build Coastguard Worker 
184*90c8c64dSAndroid Build Coastguard Worker   /// Interface flags (see SP_DEVICE_INTERFACE_DATA for details)
185*90c8c64dSAndroid Build Coastguard Worker   unsigned long flags;
186*90c8c64dSAndroid Build Coastguard Worker 
187*90c8c64dSAndroid Build Coastguard Worker   /// Device name for the interface (see SP_DEVICE_INTERFACE_DETAIL_DATA
188*90c8c64dSAndroid Build Coastguard Worker   /// for details)
189*90c8c64dSAndroid Build Coastguard Worker   wchar_t       device_name[1];
190*90c8c64dSAndroid Build Coastguard Worker } AdbInterfaceInfo;
191*90c8c64dSAndroid Build Coastguard Worker 
192*90c8c64dSAndroid Build Coastguard Worker /** \brief Creates USB interface enumerator
193*90c8c64dSAndroid Build Coastguard Worker 
194*90c8c64dSAndroid Build Coastguard Worker   This routine enumerates all USB interfaces that match provided class ID.
195*90c8c64dSAndroid Build Coastguard Worker   This routine uses SetupDiGetClassDevs SDK routine to enumerate devices that
196*90c8c64dSAndroid Build Coastguard Worker   match class ID and then SetupDiEnumDeviceInterfaces SDK routine is called
197*90c8c64dSAndroid Build Coastguard Worker   to enumerate interfaces on the devices.
198*90c8c64dSAndroid Build Coastguard Worker   @param[in] class_id Device class ID, assigned by the driver.
199*90c8c64dSAndroid Build Coastguard Worker   @param[in] exclude_not_present If true enumation will include only those
200*90c8c64dSAndroid Build Coastguard Worker          devices that are currently present.
201*90c8c64dSAndroid Build Coastguard Worker   @param[in] exclude_removed If true interfaces with SPINT_REMOVED flag set
202*90c8c64dSAndroid Build Coastguard Worker          will be not included in the enumeration.
203*90c8c64dSAndroid Build Coastguard Worker   @param[in] active_only If true only active interfaces (with flag
204*90c8c64dSAndroid Build Coastguard Worker            SPINT_ACTIVE set) will be included in the enumeration.
205*90c8c64dSAndroid Build Coastguard Worker   @return Handle to the enumerator object or NULL on failure. If NULL is
206*90c8c64dSAndroid Build Coastguard Worker           returned GetLastError() provides extended error information.
207*90c8c64dSAndroid Build Coastguard Worker */
208*90c8c64dSAndroid Build Coastguard Worker ADBWIN_API ADBAPIHANDLE __cdecl AdbEnumInterfaces(GUID class_id,
209*90c8c64dSAndroid Build Coastguard Worker                                           bool exclude_not_present,
210*90c8c64dSAndroid Build Coastguard Worker                                           bool exclude_removed,
211*90c8c64dSAndroid Build Coastguard Worker                                           bool active_only);
212*90c8c64dSAndroid Build Coastguard Worker 
213*90c8c64dSAndroid Build Coastguard Worker /** \brief Gets next interface information
214*90c8c64dSAndroid Build Coastguard Worker 
215*90c8c64dSAndroid Build Coastguard Worker   @param[in] adb_handle Handle to interface enumerator object obtained via
216*90c8c64dSAndroid Build Coastguard Worker          AdbEnumInterfaces call.
217*90c8c64dSAndroid Build Coastguard Worker   @param[out] info Upon successful completion will receive interface
218*90c8c64dSAndroid Build Coastguard Worker          information. Can be NULL. If it is NULL, upon return from this
219*90c8c64dSAndroid Build Coastguard Worker          routine size parameter will contain memory size required for the
220*90c8c64dSAndroid Build Coastguard Worker          next entry.
221*90c8c64dSAndroid Build Coastguard Worker   @param[in,out] size On the way in provides size of the memory buffer
222*90c8c64dSAndroid Build Coastguard Worker          addressed by info parameter. On the way out (only if buffer was not
223*90c8c64dSAndroid Build Coastguard Worker          big enough) will provide memory size required for the next entry.
224*90c8c64dSAndroid Build Coastguard Worker   @return true on success, false on error. If false is returned
225*90c8c64dSAndroid Build Coastguard Worker           GetLastError() provides extended error information.
226*90c8c64dSAndroid Build Coastguard Worker           ERROR_INSUFFICIENT_BUFFER indicates that buffer provided in info
227*90c8c64dSAndroid Build Coastguard Worker           parameter was not big enough and size parameter contains memory size
228*90c8c64dSAndroid Build Coastguard Worker           required for the next entry. ERROR_NO_MORE_ITEMS indicates that
229*90c8c64dSAndroid Build Coastguard Worker           enumeration is over and there are no more entries to return.
230*90c8c64dSAndroid Build Coastguard Worker */
231*90c8c64dSAndroid Build Coastguard Worker ADBWIN_API bool __cdecl AdbNextInterface(ADBAPIHANDLE adb_handle,
232*90c8c64dSAndroid Build Coastguard Worker                                  AdbInterfaceInfo* info,
233*90c8c64dSAndroid Build Coastguard Worker                                  unsigned long* size);
234*90c8c64dSAndroid Build Coastguard Worker 
235*90c8c64dSAndroid Build Coastguard Worker /** \brief Resets enumerator so next call to AdbNextInterface will start
236*90c8c64dSAndroid Build Coastguard Worker   from the beginning.
237*90c8c64dSAndroid Build Coastguard Worker 
238*90c8c64dSAndroid Build Coastguard Worker   @param[in] adb_handle Handle to interface enumerator object obtained via
239*90c8c64dSAndroid Build Coastguard Worker          AdbEnumInterfaces call.
240*90c8c64dSAndroid Build Coastguard Worker   @return true on success, false on error. If false is returned GetLastError()
241*90c8c64dSAndroid Build Coastguard Worker           provides extended error information.
242*90c8c64dSAndroid Build Coastguard Worker */
243*90c8c64dSAndroid Build Coastguard Worker ADBWIN_API bool __cdecl AdbResetInterfaceEnum(ADBAPIHANDLE adb_handle);
244*90c8c64dSAndroid Build Coastguard Worker 
245*90c8c64dSAndroid Build Coastguard Worker /** \brief Creates USB interface object
246*90c8c64dSAndroid Build Coastguard Worker 
247*90c8c64dSAndroid Build Coastguard Worker   This routine creates an object that represents a USB interface.
248*90c8c64dSAndroid Build Coastguard Worker   @param[in] interface_name Name of the interface.
249*90c8c64dSAndroid Build Coastguard Worker   @return Handle to the interface object or NULL on failure. If NULL is
250*90c8c64dSAndroid Build Coastguard Worker           returned GetLastError() provides extended error information.
251*90c8c64dSAndroid Build Coastguard Worker */
252*90c8c64dSAndroid Build Coastguard Worker ADBWIN_API ADBAPIHANDLE __cdecl AdbCreateInterfaceByName(const wchar_t* interface_name);
253*90c8c64dSAndroid Build Coastguard Worker 
254*90c8c64dSAndroid Build Coastguard Worker /** \brief Creates USB interface object based on vendor, product and
255*90c8c64dSAndroid Build Coastguard Worker   interface IDs.
256*90c8c64dSAndroid Build Coastguard Worker 
257*90c8c64dSAndroid Build Coastguard Worker   This routine creates and object that represents a USB interface on our
258*90c8c64dSAndroid Build Coastguard Worker   device. It uses AdbCreateInterfaceByName to actually do the create.
259*90c8c64dSAndroid Build Coastguard Worker   @param[in] class_id Device class ID, assigned by the driver.
260*90c8c64dSAndroid Build Coastguard Worker   @param[in] vendor_id Device vendor ID
261*90c8c64dSAndroid Build Coastguard Worker   @param[in] product_id Device product ID
262*90c8c64dSAndroid Build Coastguard Worker   @param[in] interface_id Device interface ID. This parameter is optional.
263*90c8c64dSAndroid Build Coastguard Worker          Value 0xFF indicates that interface should be addressed by vendor
264*90c8c64dSAndroid Build Coastguard Worker          and product IDs only.
265*90c8c64dSAndroid Build Coastguard Worker   @return Handle to the interface object or NULL on failure. If NULL is
266*90c8c64dSAndroid Build Coastguard Worker           returned GetLastError() provides extended error information.
267*90c8c64dSAndroid Build Coastguard Worker */
268*90c8c64dSAndroid Build Coastguard Worker ADBWIN_API ADBAPIHANDLE __cdecl AdbCreateInterface(GUID class_id,
269*90c8c64dSAndroid Build Coastguard Worker                                            unsigned short vendor_id,
270*90c8c64dSAndroid Build Coastguard Worker                                            unsigned short product_id,
271*90c8c64dSAndroid Build Coastguard Worker                                            unsigned char interface_id);
272*90c8c64dSAndroid Build Coastguard Worker 
273*90c8c64dSAndroid Build Coastguard Worker /** \brief Gets interface name.
274*90c8c64dSAndroid Build Coastguard Worker 
275*90c8c64dSAndroid Build Coastguard Worker   @param[in] adb_interface A handle to interface object created with
276*90c8c64dSAndroid Build Coastguard Worker          AdbCreateInterface call.
277*90c8c64dSAndroid Build Coastguard Worker   @param[out] buffer Buffer for the name. Can be NULL in which case
278*90c8c64dSAndroid Build Coastguard Worker          buffer_char_size will contain number of characters required for
279*90c8c64dSAndroid Build Coastguard Worker          the name.
280*90c8c64dSAndroid Build Coastguard Worker   @param[in,out] buffer_char_size On the way in supplies size (in characters)
281*90c8c64dSAndroid Build Coastguard Worker          of the buffer. On the way out, if method failed and GetLastError
282*90c8c64dSAndroid Build Coastguard Worker          reports ERROR_INSUFFICIENT_BUFFER, will contain number of characters
283*90c8c64dSAndroid Build Coastguard Worker          required for the name.
284*90c8c64dSAndroid Build Coastguard Worker   @param[in] ansi If true the name will be returned as single character
285*90c8c64dSAndroid Build Coastguard Worker          string. Otherwise name will be returned as wide character string.
286*90c8c64dSAndroid Build Coastguard Worker   @return true on success, false on failure. If false is returned
287*90c8c64dSAndroid Build Coastguard Worker           GetLastError() provides extended error information.
288*90c8c64dSAndroid Build Coastguard Worker */
289*90c8c64dSAndroid Build Coastguard Worker ADBWIN_API bool __cdecl AdbGetInterfaceName(ADBAPIHANDLE adb_interface,
290*90c8c64dSAndroid Build Coastguard Worker                                     void* buffer,
291*90c8c64dSAndroid Build Coastguard Worker                                     unsigned long* buffer_char_size,
292*90c8c64dSAndroid Build Coastguard Worker                                     bool ansi);
293*90c8c64dSAndroid Build Coastguard Worker 
294*90c8c64dSAndroid Build Coastguard Worker /** \brief Gets serial number for interface's device.
295*90c8c64dSAndroid Build Coastguard Worker 
296*90c8c64dSAndroid Build Coastguard Worker   @param[in] adb_interface A handle to interface object created with
297*90c8c64dSAndroid Build Coastguard Worker          AdbCreateInterface call.
298*90c8c64dSAndroid Build Coastguard Worker   @param[out] buffer Buffer for the serail number string. Can be NULL in which
299*90c8c64dSAndroid Build Coastguard Worker          case buffer_char_size will contain number of characters required for
300*90c8c64dSAndroid Build Coastguard Worker          the string.
301*90c8c64dSAndroid Build Coastguard Worker   @param[in,out] buffer_char_size On the way in supplies size (in characters)
302*90c8c64dSAndroid Build Coastguard Worker          of the buffer. On the way out, if method failed and GetLastError
303*90c8c64dSAndroid Build Coastguard Worker          reports ERROR_INSUFFICIENT_BUFFER, will contain number of characters
304*90c8c64dSAndroid Build Coastguard Worker          required for the name.
305*90c8c64dSAndroid Build Coastguard Worker   @param[in] ansi If true the name will be returned as single character
306*90c8c64dSAndroid Build Coastguard Worker          string. Otherwise name will be returned as wide character string.
307*90c8c64dSAndroid Build Coastguard Worker   @return true on success, false on failure. If false is returned
308*90c8c64dSAndroid Build Coastguard Worker           GetLastError() provides extended error information.
309*90c8c64dSAndroid Build Coastguard Worker */
310*90c8c64dSAndroid Build Coastguard Worker ADBWIN_API bool __cdecl AdbGetSerialNumber(ADBAPIHANDLE adb_interface,
311*90c8c64dSAndroid Build Coastguard Worker                                    void* buffer,
312*90c8c64dSAndroid Build Coastguard Worker                                    unsigned long* buffer_char_size,
313*90c8c64dSAndroid Build Coastguard Worker                                    bool ansi);
314*90c8c64dSAndroid Build Coastguard Worker 
315*90c8c64dSAndroid Build Coastguard Worker /** \brief Gets device descriptor for the USB device associated with
316*90c8c64dSAndroid Build Coastguard Worker   the given interface.
317*90c8c64dSAndroid Build Coastguard Worker 
318*90c8c64dSAndroid Build Coastguard Worker   @param[in] adb_interface A handle to interface object created with
319*90c8c64dSAndroid Build Coastguard Worker          AdbCreateInterface call.
320*90c8c64dSAndroid Build Coastguard Worker   @param[out] desc Upon successful completion will have usb device
321*90c8c64dSAndroid Build Coastguard Worker          descriptor.
322*90c8c64dSAndroid Build Coastguard Worker   @return true on success, false on failure. If false is returned
323*90c8c64dSAndroid Build Coastguard Worker           GetLastError() provides extended error information.
324*90c8c64dSAndroid Build Coastguard Worker */
325*90c8c64dSAndroid Build Coastguard Worker ADBWIN_API bool __cdecl AdbGetUsbDeviceDescriptor(ADBAPIHANDLE adb_interface,
326*90c8c64dSAndroid Build Coastguard Worker                                           USB_DEVICE_DESCRIPTOR* desc);
327*90c8c64dSAndroid Build Coastguard Worker 
328*90c8c64dSAndroid Build Coastguard Worker /** \brief Gets descriptor for the selected USB device configuration.
329*90c8c64dSAndroid Build Coastguard Worker 
330*90c8c64dSAndroid Build Coastguard Worker   @param[in] adb_interface A handle to interface object created with
331*90c8c64dSAndroid Build Coastguard Worker          AdbCreateInterface call.
332*90c8c64dSAndroid Build Coastguard Worker   @param[out] desc Upon successful completion will have usb device
333*90c8c64dSAndroid Build Coastguard Worker          configuration descriptor.
334*90c8c64dSAndroid Build Coastguard Worker   @return true on success, false on failure. If false is returned
335*90c8c64dSAndroid Build Coastguard Worker           GetLastError() provides extended error information.
336*90c8c64dSAndroid Build Coastguard Worker */
337*90c8c64dSAndroid Build Coastguard Worker ADBWIN_API bool __cdecl AdbGetUsbConfigurationDescriptor(
338*90c8c64dSAndroid Build Coastguard Worker                     ADBAPIHANDLE adb_interface,
339*90c8c64dSAndroid Build Coastguard Worker                     USB_CONFIGURATION_DESCRIPTOR* desc);
340*90c8c64dSAndroid Build Coastguard Worker 
341*90c8c64dSAndroid Build Coastguard Worker /** \brief Gets descriptor for the given interface.
342*90c8c64dSAndroid Build Coastguard Worker 
343*90c8c64dSAndroid Build Coastguard Worker   @param[in] adb_interface A handle to interface object created with
344*90c8c64dSAndroid Build Coastguard Worker          AdbCreateInterface call.
345*90c8c64dSAndroid Build Coastguard Worker   @param[out] desc Upon successful completion will have usb device
346*90c8c64dSAndroid Build Coastguard Worker          configuration descriptor.
347*90c8c64dSAndroid Build Coastguard Worker   @return true on success, false on failure. If false is returned
348*90c8c64dSAndroid Build Coastguard Worker           GetLastError() provides extended error information.
349*90c8c64dSAndroid Build Coastguard Worker */
350*90c8c64dSAndroid Build Coastguard Worker ADBWIN_API bool __cdecl AdbGetUsbInterfaceDescriptor(ADBAPIHANDLE adb_interface,
351*90c8c64dSAndroid Build Coastguard Worker                                              USB_INTERFACE_DESCRIPTOR* desc);
352*90c8c64dSAndroid Build Coastguard Worker 
353*90c8c64dSAndroid Build Coastguard Worker /** \brief Gets information about an endpoint on the given interface.
354*90c8c64dSAndroid Build Coastguard Worker 
355*90c8c64dSAndroid Build Coastguard Worker   @param[in] adb_interface A handle to interface object created with
356*90c8c64dSAndroid Build Coastguard Worker          AdbCreateInterface call.
357*90c8c64dSAndroid Build Coastguard Worker   @param[in] endpoint_index Zero-based endpoint index. There are two
358*90c8c64dSAndroid Build Coastguard Worker          shortcuts for this parameter: ADB_QUERY_BULK_WRITE_ENDPOINT_INDEX
359*90c8c64dSAndroid Build Coastguard Worker          and ADB_QUERY_BULK_READ_ENDPOINT_INDEX that provide information
360*90c8c64dSAndroid Build Coastguard Worker          about bulk write and bulk read endpoints respectively.
361*90c8c64dSAndroid Build Coastguard Worker   @param[out] info Upon successful completion will have endpoint information.
362*90c8c64dSAndroid Build Coastguard Worker   @return true on success, false on failure. If false is returned
363*90c8c64dSAndroid Build Coastguard Worker           GetLastError() provides extended error information.
364*90c8c64dSAndroid Build Coastguard Worker */
365*90c8c64dSAndroid Build Coastguard Worker ADBWIN_API bool __cdecl AdbGetEndpointInformation(ADBAPIHANDLE adb_interface,
366*90c8c64dSAndroid Build Coastguard Worker                                           unsigned char endpoint_index,
367*90c8c64dSAndroid Build Coastguard Worker                                           AdbEndpointInformation* info);
368*90c8c64dSAndroid Build Coastguard Worker 
369*90c8c64dSAndroid Build Coastguard Worker /** \brief Gets information about default bulk read endpoint on the given
370*90c8c64dSAndroid Build Coastguard Worker   interface.
371*90c8c64dSAndroid Build Coastguard Worker 
372*90c8c64dSAndroid Build Coastguard Worker   @param[in] adb_interface A handle to interface object created with
373*90c8c64dSAndroid Build Coastguard Worker          AdbCreateInterface call.
374*90c8c64dSAndroid Build Coastguard Worker   @param[out] info Upon successful completion will have endpoint information.
375*90c8c64dSAndroid Build Coastguard Worker   @return true on success, false on failure. If false is returned
376*90c8c64dSAndroid Build Coastguard Worker           GetLastError() provides extended error information.
377*90c8c64dSAndroid Build Coastguard Worker */
378*90c8c64dSAndroid Build Coastguard Worker ADBWIN_API bool __cdecl AdbGetDefaultBulkReadEndpointInformation(
379*90c8c64dSAndroid Build Coastguard Worker                     ADBAPIHANDLE adb_interface,
380*90c8c64dSAndroid Build Coastguard Worker                     AdbEndpointInformation* info);
381*90c8c64dSAndroid Build Coastguard Worker 
382*90c8c64dSAndroid Build Coastguard Worker /** \brief Gets information about default bulk write endpoint on the given
383*90c8c64dSAndroid Build Coastguard Worker   interface.
384*90c8c64dSAndroid Build Coastguard Worker 
385*90c8c64dSAndroid Build Coastguard Worker   @param[in] adb_interface A handle to interface object created with
386*90c8c64dSAndroid Build Coastguard Worker          AdbCreateInterface call.
387*90c8c64dSAndroid Build Coastguard Worker   @param[out] info Upon successful completion will have endpoint information.
388*90c8c64dSAndroid Build Coastguard Worker   @return true on success, false on failure. If false is returned
389*90c8c64dSAndroid Build Coastguard Worker           GetLastError() provides extended error information.
390*90c8c64dSAndroid Build Coastguard Worker */
391*90c8c64dSAndroid Build Coastguard Worker ADBWIN_API bool __cdecl AdbGetDefaultBulkWriteEndpointInformation(
392*90c8c64dSAndroid Build Coastguard Worker                     ADBAPIHANDLE adb_interface,
393*90c8c64dSAndroid Build Coastguard Worker                     AdbEndpointInformation* info);
394*90c8c64dSAndroid Build Coastguard Worker 
395*90c8c64dSAndroid Build Coastguard Worker /** \brief Opens an endpoint on the given interface.
396*90c8c64dSAndroid Build Coastguard Worker 
397*90c8c64dSAndroid Build Coastguard Worker   Endpoints are always opened for overlapped I/O.
398*90c8c64dSAndroid Build Coastguard Worker   @param[in] adb_interface A handle to interface object created with
399*90c8c64dSAndroid Build Coastguard Worker          AdbCreateInterface call.
400*90c8c64dSAndroid Build Coastguard Worker   @param[in] endpoint_index Zero-based endpoint index. There are two
401*90c8c64dSAndroid Build Coastguard Worker          shortcuts for this parameter: ADB_QUERY_BULK_WRITE_ENDPOINT_INDEX
402*90c8c64dSAndroid Build Coastguard Worker          and ADB_QUERY_BULK_READ_ENDPOINT_INDEX that provide information
403*90c8c64dSAndroid Build Coastguard Worker          about bulk write and bulk read endpoints respectively.
404*90c8c64dSAndroid Build Coastguard Worker   @param[in] access_type Desired access type. In the current implementation
405*90c8c64dSAndroid Build Coastguard Worker          this parameter has no effect on the way endpoint is opened. It's
406*90c8c64dSAndroid Build Coastguard Worker          always read / write access.
407*90c8c64dSAndroid Build Coastguard Worker   @param[in] sharing_mode Desired share mode. In the current implementation
408*90c8c64dSAndroid Build Coastguard Worker          this parameter has no effect on the way endpoint is opened. It's
409*90c8c64dSAndroid Build Coastguard Worker          always shared for read / write.
410*90c8c64dSAndroid Build Coastguard Worker   @return Handle to the opened endpoint object or NULL on failure. If NULL is
411*90c8c64dSAndroid Build Coastguard Worker           returned GetLastError() provides extended error information.
412*90c8c64dSAndroid Build Coastguard Worker */
413*90c8c64dSAndroid Build Coastguard Worker ADBWIN_API ADBAPIHANDLE __cdecl AdbOpenEndpoint(ADBAPIHANDLE adb_interface,
414*90c8c64dSAndroid Build Coastguard Worker                                         unsigned char endpoint_index,
415*90c8c64dSAndroid Build Coastguard Worker                                         AdbOpenAccessType access_type,
416*90c8c64dSAndroid Build Coastguard Worker                                         AdbOpenSharingMode sharing_mode);
417*90c8c64dSAndroid Build Coastguard Worker 
418*90c8c64dSAndroid Build Coastguard Worker /** \brief Opens default bulk read endpoint on the given interface.
419*90c8c64dSAndroid Build Coastguard Worker 
420*90c8c64dSAndroid Build Coastguard Worker   Endpoints are always opened for overlapped I/O.
421*90c8c64dSAndroid Build Coastguard Worker   @param[in] adb_interface A handle to interface object created with
422*90c8c64dSAndroid Build Coastguard Worker          AdbCreateInterface call.
423*90c8c64dSAndroid Build Coastguard Worker   @param[in] access_type Desired access type. In the current implementation
424*90c8c64dSAndroid Build Coastguard Worker          this parameter has no effect on the way endpoint is opened. It's
425*90c8c64dSAndroid Build Coastguard Worker          always read / write access.
426*90c8c64dSAndroid Build Coastguard Worker   @param[in] sharing_mode Desired share mode. In the current implementation
427*90c8c64dSAndroid Build Coastguard Worker          this parameter has no effect on the way endpoint is opened. It's
428*90c8c64dSAndroid Build Coastguard Worker          always shared for read / write.
429*90c8c64dSAndroid Build Coastguard Worker   @return Handle to the opened endpoint object or NULL on failure. If NULL is
430*90c8c64dSAndroid Build Coastguard Worker           returned GetLastError() provides extended error information.
431*90c8c64dSAndroid Build Coastguard Worker */
432*90c8c64dSAndroid Build Coastguard Worker ADBWIN_API ADBAPIHANDLE __cdecl AdbOpenDefaultBulkReadEndpoint(
433*90c8c64dSAndroid Build Coastguard Worker                             ADBAPIHANDLE adb_interface,
434*90c8c64dSAndroid Build Coastguard Worker                             AdbOpenAccessType access_type,
435*90c8c64dSAndroid Build Coastguard Worker                             AdbOpenSharingMode sharing_mode);
436*90c8c64dSAndroid Build Coastguard Worker 
437*90c8c64dSAndroid Build Coastguard Worker /** \brief Opens default bulk write endpoint on the given interface.
438*90c8c64dSAndroid Build Coastguard Worker 
439*90c8c64dSAndroid Build Coastguard Worker   Endpoints are always opened for overlapped I/O.
440*90c8c64dSAndroid Build Coastguard Worker   @param[in] adb_interface A handle to interface object created with
441*90c8c64dSAndroid Build Coastguard Worker          AdbCreateInterface call.
442*90c8c64dSAndroid Build Coastguard Worker   @param[in] access_type Desired access type. In the current implementation
443*90c8c64dSAndroid Build Coastguard Worker          this parameter has no effect on the way endpoint is opened. It's
444*90c8c64dSAndroid Build Coastguard Worker          always read / write access.
445*90c8c64dSAndroid Build Coastguard Worker   @param[in] sharing_mode Desired share mode. In the current implementation
446*90c8c64dSAndroid Build Coastguard Worker          this parameter has no effect on the way endpoint is opened. It's
447*90c8c64dSAndroid Build Coastguard Worker          always shared for read / write.
448*90c8c64dSAndroid Build Coastguard Worker   @return Handle to the opened endpoint object or NULL on failure. If NULL is
449*90c8c64dSAndroid Build Coastguard Worker           returned GetLastError() provides extended error information.
450*90c8c64dSAndroid Build Coastguard Worker */
451*90c8c64dSAndroid Build Coastguard Worker ADBWIN_API ADBAPIHANDLE __cdecl AdbOpenDefaultBulkWriteEndpoint(
452*90c8c64dSAndroid Build Coastguard Worker                             ADBAPIHANDLE adb_interface,
453*90c8c64dSAndroid Build Coastguard Worker                             AdbOpenAccessType access_type,
454*90c8c64dSAndroid Build Coastguard Worker                             AdbOpenSharingMode sharing_mode);
455*90c8c64dSAndroid Build Coastguard Worker 
456*90c8c64dSAndroid Build Coastguard Worker /** \brief Gets handle to interface object for the given endpoint
457*90c8c64dSAndroid Build Coastguard Worker 
458*90c8c64dSAndroid Build Coastguard Worker   @param[in] adb_endpoint A handle to opened endpoint object, obtained via one
459*90c8c64dSAndroid Build Coastguard Worker          of the AdbOpenXxxEndpoint calls.
460*90c8c64dSAndroid Build Coastguard Worker   @return Handle to the interface for this endpoint or NULL on failure. If NULL
461*90c8c64dSAndroid Build Coastguard Worker           is returned GetLastError() provides extended error information.
462*90c8c64dSAndroid Build Coastguard Worker */
463*90c8c64dSAndroid Build Coastguard Worker ADBWIN_API ADBAPIHANDLE __cdecl AdbGetEndpointInterface(ADBAPIHANDLE adb_endpoint);
464*90c8c64dSAndroid Build Coastguard Worker 
465*90c8c64dSAndroid Build Coastguard Worker /** \brief Gets information about the given endpoint.
466*90c8c64dSAndroid Build Coastguard Worker 
467*90c8c64dSAndroid Build Coastguard Worker   @param[in] adb_endpoint A handle to opened endpoint object, obtained via one
468*90c8c64dSAndroid Build Coastguard Worker          of the AdbOpenXxxEndpoint calls.
469*90c8c64dSAndroid Build Coastguard Worker   @param[out] info Upon successful completion will have endpoint information.
470*90c8c64dSAndroid Build Coastguard Worker   @return true on success, false on failure. If false is returned
471*90c8c64dSAndroid Build Coastguard Worker           GetLastError() provides extended error information.
472*90c8c64dSAndroid Build Coastguard Worker */
473*90c8c64dSAndroid Build Coastguard Worker ADBWIN_API bool __cdecl AdbQueryInformationEndpoint(ADBAPIHANDLE adb_endpoint,
474*90c8c64dSAndroid Build Coastguard Worker                                             AdbEndpointInformation* info);
475*90c8c64dSAndroid Build Coastguard Worker 
476*90c8c64dSAndroid Build Coastguard Worker /** \brief Asynchronously reads from the given endpoint.
477*90c8c64dSAndroid Build Coastguard Worker 
478*90c8c64dSAndroid Build Coastguard Worker   @param[in] adb_endpoint A handle to opened endpoint object, obtained via one
479*90c8c64dSAndroid Build Coastguard Worker          of the AdbOpenXxxEndpoint calls.
480*90c8c64dSAndroid Build Coastguard Worker   @param[out] buffer Pointer to the buffer that receives the data.
481*90c8c64dSAndroid Build Coastguard Worker   @param[in] bytes_to_read Number of bytes to be read.
482*90c8c64dSAndroid Build Coastguard Worker   @param[out] bytes_read Number of bytes read. Can be NULL.
483*90c8c64dSAndroid Build Coastguard Worker   @param[in] event_handle Event handle that should be signaled when async I/O
484*90c8c64dSAndroid Build Coastguard Worker          completes. Can be NULL. If it's not NULL this handle will be used to
485*90c8c64dSAndroid Build Coastguard Worker          initialize OVERLAPPED structure for this I/O.
486*90c8c64dSAndroid Build Coastguard Worker   @param[in] time_out A timeout (in milliseconds) required for this I/O to
487*90c8c64dSAndroid Build Coastguard Worker          complete. Zero value for this parameter means that there is no
488*90c8c64dSAndroid Build Coastguard Worker          timeout for this I/O.
489*90c8c64dSAndroid Build Coastguard Worker   @return A handle to IO completion object or NULL on failure. If NULL is
490*90c8c64dSAndroid Build Coastguard Worker           returned GetLastError() provides extended error information.
491*90c8c64dSAndroid Build Coastguard Worker */
492*90c8c64dSAndroid Build Coastguard Worker ADBWIN_API ADBAPIHANDLE __cdecl AdbReadEndpointAsync(ADBAPIHANDLE adb_endpoint,
493*90c8c64dSAndroid Build Coastguard Worker                                              void* buffer,
494*90c8c64dSAndroid Build Coastguard Worker                                              unsigned long bytes_to_read,
495*90c8c64dSAndroid Build Coastguard Worker                                              unsigned long* bytes_read,
496*90c8c64dSAndroid Build Coastguard Worker                                              unsigned long time_out,
497*90c8c64dSAndroid Build Coastguard Worker                                              HANDLE event_handle);
498*90c8c64dSAndroid Build Coastguard Worker 
499*90c8c64dSAndroid Build Coastguard Worker /** \brief Asynchronously writes to the given endpoint.
500*90c8c64dSAndroid Build Coastguard Worker 
501*90c8c64dSAndroid Build Coastguard Worker   @param[in] adb_endpoint A handle to opened endpoint object, obtained via one
502*90c8c64dSAndroid Build Coastguard Worker          of the AdbOpenXxxEndpoint calls.
503*90c8c64dSAndroid Build Coastguard Worker   @param[in] buffer Pointer to the buffer containing the data to be written.
504*90c8c64dSAndroid Build Coastguard Worker   @param[in] bytes_to_write Number of bytes to be written.
505*90c8c64dSAndroid Build Coastguard Worker   @param[out] bytes_written Number of bytes written. Can be NULL.
506*90c8c64dSAndroid Build Coastguard Worker   @param[in] event_handle Event handle that should be signaled when async I/O
507*90c8c64dSAndroid Build Coastguard Worker          completes. Can be NULL. If it's not NULL this handle will be used to
508*90c8c64dSAndroid Build Coastguard Worker          initialize OVERLAPPED structure for this I/O.
509*90c8c64dSAndroid Build Coastguard Worker   @param[in] time_out A timeout (in milliseconds) required for this I/O to
510*90c8c64dSAndroid Build Coastguard Worker          complete. Zero value for this parameter means that there is no
511*90c8c64dSAndroid Build Coastguard Worker          timeout for this I/O.
512*90c8c64dSAndroid Build Coastguard Worker   @return A handle to IO completion object or NULL on failure. If NULL is
513*90c8c64dSAndroid Build Coastguard Worker           returned GetLastError() provides extended error information.
514*90c8c64dSAndroid Build Coastguard Worker */
515*90c8c64dSAndroid Build Coastguard Worker ADBWIN_API ADBAPIHANDLE __cdecl AdbWriteEndpointAsync(ADBAPIHANDLE adb_endpoint,
516*90c8c64dSAndroid Build Coastguard Worker                                               void* buffer,
517*90c8c64dSAndroid Build Coastguard Worker                                               unsigned long bytes_to_write,
518*90c8c64dSAndroid Build Coastguard Worker                                               unsigned long* bytes_written,
519*90c8c64dSAndroid Build Coastguard Worker                                               unsigned long time_out,
520*90c8c64dSAndroid Build Coastguard Worker                                               HANDLE event_handle);
521*90c8c64dSAndroid Build Coastguard Worker 
522*90c8c64dSAndroid Build Coastguard Worker /** \brief Synchronously reads from the given endpoint.
523*90c8c64dSAndroid Build Coastguard Worker 
524*90c8c64dSAndroid Build Coastguard Worker   @param[in] adb_endpoint A handle to opened endpoint object, obtained via one
525*90c8c64dSAndroid Build Coastguard Worker          of the AdbOpenXxxEndpoint calls.
526*90c8c64dSAndroid Build Coastguard Worker   @param[out] buffer Pointer to the buffer that receives the data.
527*90c8c64dSAndroid Build Coastguard Worker   @param[in] bytes_to_read Number of bytes to be read.
528*90c8c64dSAndroid Build Coastguard Worker   @param[out] bytes_read Number of bytes read. Can be NULL.
529*90c8c64dSAndroid Build Coastguard Worker   @param[in] time_out A timeout (in milliseconds) required for this I/O to
530*90c8c64dSAndroid Build Coastguard Worker          complete. Zero value for this parameter means that there is no
531*90c8c64dSAndroid Build Coastguard Worker          timeout for this I/O.
532*90c8c64dSAndroid Build Coastguard Worker   @return true on success and false on failure. If false is
533*90c8c64dSAndroid Build Coastguard Worker           returned GetLastError() provides extended error information.
534*90c8c64dSAndroid Build Coastguard Worker */
535*90c8c64dSAndroid Build Coastguard Worker ADBWIN_API bool __cdecl AdbReadEndpointSync(ADBAPIHANDLE adb_endpoint,
536*90c8c64dSAndroid Build Coastguard Worker                                     void* buffer,
537*90c8c64dSAndroid Build Coastguard Worker                                     unsigned long bytes_to_read,
538*90c8c64dSAndroid Build Coastguard Worker                                     unsigned long* bytes_read,
539*90c8c64dSAndroid Build Coastguard Worker                                     unsigned long time_out);
540*90c8c64dSAndroid Build Coastguard Worker 
541*90c8c64dSAndroid Build Coastguard Worker /** \brief Synchronously writes to the given endpoint.
542*90c8c64dSAndroid Build Coastguard Worker 
543*90c8c64dSAndroid Build Coastguard Worker   @param[in] adb_endpoint A handle to opened endpoint object, obtained via one
544*90c8c64dSAndroid Build Coastguard Worker          of the AdbOpenXxxEndpoint calls.
545*90c8c64dSAndroid Build Coastguard Worker   @param[in] buffer Pointer to the buffer containing the data to be written.
546*90c8c64dSAndroid Build Coastguard Worker   @param[in] bytes_to_write Number of bytes to be written.
547*90c8c64dSAndroid Build Coastguard Worker   @param[out] bytes_written Number of bytes written. Can be NULL.
548*90c8c64dSAndroid Build Coastguard Worker   @param[in] time_out A timeout (in milliseconds) required for this I/O to
549*90c8c64dSAndroid Build Coastguard Worker          complete. Zero value for this parameter means that there is no
550*90c8c64dSAndroid Build Coastguard Worker          timeout for this I/O.
551*90c8c64dSAndroid Build Coastguard Worker   @return true on success and false on failure. If false is
552*90c8c64dSAndroid Build Coastguard Worker           returned GetLastError() provides extended error information.
553*90c8c64dSAndroid Build Coastguard Worker */
554*90c8c64dSAndroid Build Coastguard Worker ADBWIN_API bool __cdecl AdbWriteEndpointSync(ADBAPIHANDLE adb_endpoint,
555*90c8c64dSAndroid Build Coastguard Worker                                      void* buffer,
556*90c8c64dSAndroid Build Coastguard Worker                                      unsigned long bytes_to_write,
557*90c8c64dSAndroid Build Coastguard Worker                                      unsigned long* bytes_written,
558*90c8c64dSAndroid Build Coastguard Worker                                      unsigned long time_out);
559*90c8c64dSAndroid Build Coastguard Worker 
560*90c8c64dSAndroid Build Coastguard Worker /** \brief Gets overlapped I/O result for async I/O performed on the
561*90c8c64dSAndroid Build Coastguard Worker   given endpoint.
562*90c8c64dSAndroid Build Coastguard Worker 
563*90c8c64dSAndroid Build Coastguard Worker   @param[in] adb_io_completion A handle to an I/O completion object returned
564*90c8c64dSAndroid Build Coastguard Worker          from AdbRead/WriteAsync routines.
565*90c8c64dSAndroid Build Coastguard Worker   @param[out] ovl_data Buffer for the copy of this object's OVERLAPPED
566*90c8c64dSAndroid Build Coastguard Worker          structure. Can be NULL.
567*90c8c64dSAndroid Build Coastguard Worker   @param[out] bytes_transferred Pointer to a variable that receives the
568*90c8c64dSAndroid Build Coastguard Worker          number of bytes that were actually transferred by a read or write
569*90c8c64dSAndroid Build Coastguard Worker          operation. See SDK doc on GetOvelappedResult for more information.
570*90c8c64dSAndroid Build Coastguard Worker          Unlike regular GetOvelappedResult call this parameter can be NULL.
571*90c8c64dSAndroid Build Coastguard Worker   @param[in] wait If this parameter is true, the method does not return
572*90c8c64dSAndroid Build Coastguard Worker          until the operation has been completed. If this parameter is false
573*90c8c64dSAndroid Build Coastguard Worker          and the operation is still pending, the method returns false and
574*90c8c64dSAndroid Build Coastguard Worker          the GetLastError function returns ERROR_IO_INCOMPLETE.
575*90c8c64dSAndroid Build Coastguard Worker   @return true if I/O has been completed or false on failure or if request
576*90c8c64dSAndroid Build Coastguard Worker          is not yet completed. If false is returned GetLastError() provides
577*90c8c64dSAndroid Build Coastguard Worker          extended error information. If GetLastError returns
578*90c8c64dSAndroid Build Coastguard Worker          ERROR_IO_INCOMPLETE it means that I/O is not yet completed.
579*90c8c64dSAndroid Build Coastguard Worker */
580*90c8c64dSAndroid Build Coastguard Worker ADBWIN_API bool __cdecl AdbGetOvelappedIoResult(ADBAPIHANDLE adb_io_completion,
581*90c8c64dSAndroid Build Coastguard Worker                                         LPOVERLAPPED overlapped,
582*90c8c64dSAndroid Build Coastguard Worker                                         unsigned long* bytes_transferred,
583*90c8c64dSAndroid Build Coastguard Worker                                         bool wait);
584*90c8c64dSAndroid Build Coastguard Worker 
585*90c8c64dSAndroid Build Coastguard Worker /** \brief Checks if overlapped I/O has been completed.
586*90c8c64dSAndroid Build Coastguard Worker 
587*90c8c64dSAndroid Build Coastguard Worker   @param[in] adb_io_completion A handle to an I/O completion object returned
588*90c8c64dSAndroid Build Coastguard Worker          from AdbRead/WriteAsync routines.
589*90c8c64dSAndroid Build Coastguard Worker   @return true if I/O has been completed or false if it's still
590*90c8c64dSAndroid Build Coastguard Worker           incomplete. Regardless of the returned value, caller should
591*90c8c64dSAndroid Build Coastguard Worker           check GetLastError to validate that handle was OK.
592*90c8c64dSAndroid Build Coastguard Worker */
593*90c8c64dSAndroid Build Coastguard Worker ADBWIN_API bool __cdecl AdbHasOvelappedIoComplated(ADBAPIHANDLE adb_io_completion);
594*90c8c64dSAndroid Build Coastguard Worker 
595*90c8c64dSAndroid Build Coastguard Worker /** \brief Closes handle previously opened with one of the API calls
596*90c8c64dSAndroid Build Coastguard Worker 
597*90c8c64dSAndroid Build Coastguard Worker   @param[in] adb_handle ADB handle previously opened with one of the API calls
598*90c8c64dSAndroid Build Coastguard Worker   @return true on success or false on failure. If false is returned
599*90c8c64dSAndroid Build Coastguard Worker           GetLastError() provides extended error information.
600*90c8c64dSAndroid Build Coastguard Worker */
601*90c8c64dSAndroid Build Coastguard Worker ADBWIN_API bool __cdecl AdbCloseHandle(ADBAPIHANDLE adb_handle);
602*90c8c64dSAndroid Build Coastguard Worker 
603*90c8c64dSAndroid Build Coastguard Worker #endif  // ANDROID_USB_API_ADBWINAPI_H__
604