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