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